Title: Checkbox onclick
Last modified: June 28, 2018

---

# Checkbox onclick

 *  [nikodemski2002](https://wordpress.org/support/users/nikodemski2002/)
 * (@nikodemski2002)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/checkbox-onclick/)
 * Hi again. Is there any way to add onclick attribute to checkbox in [pdb_singup].
   
   Or is there just any another way to make other singup form elements show or hide,
   depeanding on checkbox state. (Of course i mean the checkbox which is the pdb_singup
   element, not my own HTML element.)
    -  This topic was modified 7 years, 10 months ago by [nikodemski2002](https://wordpress.org/support/users/nikodemski2002/).
    -  This topic was modified 7 years, 10 months ago by [nikodemski2002](https://wordpress.org/support/users/nikodemski2002/).
    -  This topic was modified 7 years, 10 months ago by [nikodemski2002](https://wordpress.org/support/users/nikodemski2002/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/checkbox-onclick/#post-10446089)
 * This can only be done using a [custom template](https://xnau.com/work/wordpress-plugins/participants-database/participants-database-documentation/pdb-templates/).
   Assuming you have some coding skills, you’d need to add your onclick attribute
   to the element just before it is shown on the page. For example:
 *     ```
       <?php while ( $this->have_fields() ) : $this->the_field(); ?>
   
         <?php if ( $this->field->name === 'agree' ) {
           $this->field->attributes['onclick'] = 'alert("clicked!!")';
         } ?>
       ```
   
    -  This reply was modified 7 years, 10 months ago by [xnau webdesign](https://wordpress.org/support/users/xnau/).
    -  This reply was modified 7 years, 10 months ago by [xnau webdesign](https://wordpress.org/support/users/xnau/).
 *  Thread Starter [nikodemski2002](https://wordpress.org/support/users/nikodemski2002/)
 * (@nikodemski2002)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/checkbox-onclick/#post-10472604)
 * The name of field i want to have onclick attribute is event, and values of this
   checkbox is tak and nie (yes and no in polish). And I paste code to the pdb-singup-
   custom php file, after the
    `<?php while ( $this->have_fields() ) : $this->the_field();?
   >` and it looks like that
 *     ```
                   <?php if ( $this->field->event === 'tak' ) {
           $this->field->attributes['onclick'] = 'alert("clicked!!")';
         } ?>
       ```
   
 * And I still don’t see the onclick attribute at the chrome inspect element.
    Did
   I make something wrong, at the php code or this attribute is just unseeable at
   chrome inspect element?
    -  This reply was modified 7 years, 10 months ago by [nikodemski2002](https://wordpress.org/support/users/nikodemski2002/).
    -  This reply was modified 7 years, 10 months ago by [nikodemski2002](https://wordpress.org/support/users/nikodemski2002/).
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/checkbox-onclick/#post-10474140)
 * You need to check the name of the field like this:
 * `$this->field->name === 'event'`
 * if you need to check the value also, you can check that with:
 * `$this->field->name === 'event' && $this->field->value === 'tak'`

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Checkbox onclick’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

## Tags

 * [login_form](https://wordpress.org/support/topic-tag/login_form/)

 * 3 replies
 * 2 participants
 * Last reply from: [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/checkbox-onclick/#post-10474140)
 * Status: not resolved