You are viewing limited content. For full access, please sign in.

Question

Question

Select/deselect all check boxes in a form field

asked on August 17, 2016

Looking at some of the forms I've been working on recently, I'm thinking that in some instances, when there are a ton of check boxes, it might be nice to have the ability to add in a Select/Deselect All option?  

I wasn't sure if this could be accomplished by JavaScript, but if so, if someone could provide me this that'd be great - otherwise might this be considered as an enhancement? laugh

Thanks to anyone who can help!

Marty Gaffney - Network Technician

Town of Okotoks

0 0

Answer

SELECTED ANSWER
replied on August 17, 2016

You can also refer to this previous Answers thread.

2 0

Replies

replied on August 17, 2016

Hi Marty,

 

I did something a while back and used this link as reference.

 

The code should work the same. Just be mindful of the Checkall box and change it to use a class of "checkAll".

 

Then change the jquery to

$("input:checkbox .checkAll").change(function () {
    $("input:checkbox").prop('checked', $(this).prop("checked"));
});

Cheers,

Carl

2 0
replied on August 18, 2016

Thanks, everyone - not sure how I missed that previous answer when I searched before.  Nonetheless, thanks to all of you for your help with this!

Marty

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.