Skip to content

Instantly share code, notes, and snippets.

@tuanbbhero
Created January 30, 2019 02:25
Show Gist options
  • Save tuanbbhero/2320a2756cae28b4723c6903a5d94c77 to your computer and use it in GitHub Desktop.
Save tuanbbhero/2320a2756cae28b4723c6903a5d94c77 to your computer and use it in GitHub Desktop.
Auto click Next Page in Multi-Page Caldera Forms.
/** 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