Skip to content

Commit

Permalink
gpasc-radio-button-toggle.js: Added snippet to toggle GPASC auto sa…
Browse files Browse the repository at this point in the history
…ve client side using radio buttons.
  • Loading branch information
veryspry committed Feb 21, 2023
1 parent 076e32b commit 17f32d4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions gp-advanced-save-and-continue/gpasc-radio-button-toggle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
var formId = 5;
/**
* Gravity Perks // Advanced Save and Continue // Toggle GPASC with Radio Buttons
* https://gravitywiz.com/documentation/gravity-forms-advanced-save-continue/
*
* This snippet allows you to toggle GPASC client side with radio buttons.
*/

// change this to match your form ID
var formId = 1;
// change this to match the radio button field you'd like to use to control this
var radioButtonFieldId = 2;
// change this to match the radio button input ID you'd like to use to enable GPASC
var enableInputId = 0;
// change this to match the radio button input ID you'd like to use to disable GPASC
var disableInputId = 1;

var gpascInstanceKey = 'GPASC_' + formId;
var enabledSelector = '#choice_' + formId + '_1_0';
var disabledSelector = '#choice_' + formId + '_1_1'
var enabledSelector = '#choice_' + formId + '_' + radioButtonFieldId + '_' + enableInputId;
var disabledSelector = '#choice_' + formId + '_' + radioButtonFieldId + '_' + disableInputId;

function enableGPASC() {
if (window[gpascInstanceKey] && window[gpascInstanceKey].enable) {
Expand All @@ -11,7 +26,7 @@ function enableGPASC() {

function disableGPASC() {
if (window[gpascInstanceKey] && window[gpascInstanceKey].enable) {
window[gpascInstanceKey].disable();
window[gpascInstanceKey].disable({ resetCookieModal: true });
}
}

Expand Down

0 comments on commit 17f32d4

Please sign in to comment.