• Resolved astreck2

    (@astreck2)


    Hi,

    I’m trying to set up a form with 1 field – a dropdown selection. Ideally I’d like as soon as a dropdown option is selected it will automatically redirect to a page without having to hit the submit button.

    Currently I have conditional logic set up as follows:
    Option 1 goes to page 1
    Option 2 goes to page 2
    Option 3 goes to page 3
    and so on.

    How I have it set up works – when I select an option and hit submit it redirects to the correct page based on my selection.

    However, I’d like to remove the extra step of having to hit a button, is there a way that once an option is selected it will automatically redirect to a page? Not sure if this is possible.

    Thanks,
    Ashley

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @astreck2

    I hope you are doing well,

    We can use some JavaScript here but to make sure we are on the same page, you would like to skip all the submissions?

    Best Regards
    Patrick Freitas

    Thread Starter astreck2

    (@astreck2)

    Hi, yes that is correct. What Javascript would I add?

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @astreck2

    I pinged our SLS Team to review this and see what will be possible in this case. We will post an update here as soon as more information is available.

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi again @astreck2

    This snippet should help as a mu-plugin:

    add_action( 'wp_footer', 'wpmudev_auto_submit_selction_form', 9999 );
    function wpmudev_auto_submit_selction_form() {
        global $post;
        if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) {
            return;
        }
        ?>
    	<script type="text/javascript">
    	jQuery(document).ready(function($) {
            setTimeout(function() {
    			$('.forminator-custom-form').trigger('after.load.forminator');
            }, 100);
    
            $(document).on('after.load.forminator', function(e, form_id) {
                if ( e.target.id == 'forminator-module-1609' ) { // Please change the form ID.
                    $('#select-1 select').on('select2:select', function(ev) { 
    					$('#forminator-module-1609 .forminator-button-submit').trigger('click');
    				});
                }
            });
        });
        </script>
        <?php
    }

    Please note to change 1609 in forminator-module-1609 to your form ID, and #select-1 to your select ID.

    He is a guide on how to install mu-plugin:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Kind Regards,
    Kris

    Thread Starter astreck2

    (@astreck2)

    Hi – it didn’t quite work for me, but I’ve decided to keep the button. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect based on selection automatically’ is closed to new replies.