• Resolved owlbooksdk

    (@owlbooksdk)


    Hello,

    I have a form with over 100 checkboxes. I would like to have either a link or a button that will toggle the select or deselect of all checkboxes. Is there a way to do this? I tried to find a OnClick Event for the button, but I can’t seem to find anything. Thank you in advance for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @owlbooksdk

    The process is simple. Assuming the checkbox field is the fieldname1. If you want to tick all its choices at once by pressing a button, insert a button field in the form with the piece of code below as its onclick event:

    
    jQuery('[id*="fieldname1_"]').prop('checked', true).change();
    

    If you want to include a button that untick all of them:

    
    jQuery('[id*="fieldname1_"]').prop('checked', false).change();
    

    Best regards.

    Thread Starter owlbooksdk

    (@owlbooksdk)

    This works like a charm! Can you help me out a bit more on this? These checkboxes are grouped into multiple fieldnames. So how would I write that to incorporate fieldname40, fieldname41, and fieldname42 for example?

    Thank you advance for your help! ??

    Plugin Author codepeople

    (@codepeople)

    Hello @owlbooksdk

    The onclick events would be:

    
    jQuery('[id*="fieldname40_"],[id*="fieldname41_"],[id*="fieldname42_"]').prop('checked', true).change();
    

    and

    
    jQuery('[id*="fieldname40_"],[id*="fieldname41_"],[id*="fieldname42_"]').prop('checked', false).change();
    

    Best regards.

    • This reply was modified 4 years ago by codepeople.
    Thread Starter owlbooksdk

    (@owlbooksdk)

    Ahhhhh, thank you a million! ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Link or Button to Select All Checkboxes in Form’ is closed to new replies.