Select All Checkboxes

$('#choice_7_1').click(function() {
$(this).parents('#input_2_7').find(':checkbox').attr('checked', this.checked);
});

4 Comments

You must be logged in to post a comment.


  1. I use my own themes and would toss this in a theme scripts.js file. It would probably be better to do a custom page template and just put an inline javascript code block.


  2. Curious, are you adding this to one of the Gravity Forms script files? (if so which one)

    Or in some other script file (maybe the theme or anywhere else)


  3. Sweet!


  4. Needed this for a client project, thanks! I improved upon it to make it more generic so you don't have to look up individual IDs on elements:

    jQuery(document).ready(function(){
    // Check all in Gravity Forms
    jQuery('.checkall li:first-child input').click(function() {
    jQuery(this).parent('li').parent('ul').find(':checkbox').attr('checked', this.checked);
    });
    });

    Just add a class "checkall" to your checkbox form item in Gravity Forms, it assumes the first item in the list will be the "All" option.