Created
February 7, 2015 00:00
-
-
Save carlitoescobar/c5172a5056c71b0becb4 to your computer and use it in GitHub Desktop.
Gravity Forms check all function (jQuery)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. |
It should go in the footer.php file, just before the closing tag. Make sure you wrap this in <script> tags.
Thank you for sharing!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Carlito,
I am very much interested in using this function in a Gravity Forms form.
I just don't know how to implement this in WordPress/Gravity Forms.
Does it go into the functions.php?
Can it be used as a check/un-check all function?
Cheers
ThePJ