Created
January 30, 2019 02:25
-
-
Save tuanbbhero/2320a2756cae28b4723c6903a5d94c77 to your computer and use it in GitHub Desktop.
Auto click Next Page in Multi-Page Caldera Forms.
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
/** Auto click Next Page in Multi-Page Caldera Forms */ | |
jQuery( document ).ready( function( $ ) { | |
//find highest page | |
var highest_page = 1; | |
//IMPORTANT: Change form ID to match your form | |
$( '.CF5c51040f84172 .caldera-form-page' ).each( function () { | |
highest_page = $(this).data('formpage'); | |
}); | |
/** When radio field is selected go to next page */ | |
//IMPORTANT: Change form ID to match your form | |
$('.CF5c51040f84172 input:radio').on('change', function () { | |
var $this = $(this); | |
var $form = $(this).closest('form.caldera_forms_form'), | |
current_page = $form.find('.caldera-form-page:visible').data('formpage'); | |
//check if we're on the last page | |
if ( highest_page == current_page ) { | |
//find and click submit | |
$form.find( 'input[type="submit"]' ).trigger( 'click') ; | |
}else{ | |
//find and click next page button | |
$form.find('[data-formpage="' + current_page + '"]').find('.cf-page-btn-next').trigger('click'); | |
} | |
}); | |
/** Hide next page buttons and submit buttons*/ | |
//IMPORTANT: Change form ID to match your form | |
$('.CF5c51040f84172').find('.cf-page-btn-next, input[type="submit"]').hide().attr('aria-hidden', true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment