Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active June 23, 2017 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/9a9697056c04e8c24104d17a47c99033 to your computer and use it in GitHub Desktop.
Save Shelob9/9a9697056c04e8c24104d17a47c99033 to your computer and use it in GitHub Desktop.
jQuery( document ).ready( function( $ ) {
//find highest page
var highest_page = 1;
//IMPORTANT: Change form ID to match your form
$( '.CF594939554ca46 .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
$('.CF594939554ca46 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
$('.CF594939554ca46').find('.cf-page-btn-next, input[type="submit"]').hide().attr('aria-hidden', true);
});
jQuery( document ).ready( function( $ ) {
/** When radio field is selected go to next page */
//IMPORTANT: Change form ID to match your form
$( '.CF594939554ca46 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');
$form.find( '[data-formpage="' + current_page + '"]').find( '.cf-page-btn-next' ).trigger( 'click' );
});
/** Hide next page buttons */
//IMPORTANT: Change form ID to match your form
$( '.CF594939554ca46' ).find( '.cf-page-btn-next' ).hide().attr( 'aria-hidden', true );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment