• 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.)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author xnau webdesign

    (@xnau)

    This can only be done using a custom template. 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!!")';
      } ?>
    Thread Starter nikodemski2002

    (@nikodemski2002)

    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?

    Plugin Author xnau webdesign

    (@xnau)

    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.