Home / Admin / How to Automatically Submit a Form with a Field Choice
Duplicate Snippet

Embed Snippet on Your Site

How to Automatically Submit a Form with a Field Choice

<10
Code Preview
php
<?php
/**
 * Trigger submit from checkbox click
 *
 * @link https://wpforms.com/developers/how-to-automatically-submit-a-form-with-a-field-choice/
 */
  
function wpf_dev_automatic_submit_form( ) {
?>
  
<script type="text/javascript">
     
jQuery(function($){
  
        var event = jQuery.Event( "submit" );
     
        jQuery("input:checkbox").change(
            function()
            {
                // when any checkbox is checked, trigger this function
                if( jQuery(this).is(":checked") )
                {
                    // only run this function for the form ID 3046
                    jQuery("#wpforms-form-3046").submit();
                }
            }
        )
  
    });
  
    </script>
  
<?php
}
  
add_action( 'wpforms_wp_footer_end', 'wpf_dev_automatic_submit_form', 30 );

Comments

Add a Comment