Created
November 11, 2021 03:11
-
-
Save claygriffiths/96b952f23dad578a82ac0c2337e0faf3 to your computer and use it in GitHub Desktop.
Gravity Forms: Automatically Check Checkbox
This file contains 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
/** | |
* Gravity Perks // GP Populate Anything // Automatically Check Checkboxes | |
* http://gravitywiz.com/documentation/gravity-forms-populate-anything | |
* | |
* Instructions: | |
* 1. Install our free Custom Javascript for Gravity Forms plugin. | |
* Download the plugin here: https://gravitywiz.com/gravity-forms-custom-javascript/ | |
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin. | |
*. 3. This snippet is meant to be a starting point. You will need to update the selectors accordingly | |
*/ | |
// Select all choices for field ID 1 on initial load | |
jQuery('#button_1_select_all').each(function() { | |
gformToggleCheckboxes(this); | |
}); | |
// Select all choices for field ID 2 whenever its choices are repopulated dynamically | |
jQuery(document).on('gppa_updated_batch_fields', function(event, formId, fieldIds) { | |
if (formId != GFFORMID) { | |
return; | |
} | |
jQuery('#button_2_select_all').each(function() { | |
gformToggleCheckboxes(this); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/experimental/gppa-select-all-checkboxes.js