• Resolved mmagnani

    (@mmagnani)


    Hello,

    My signup form with same page Thanks Message is far from the top of the page.

    Is there a way to make it scroll to its position after submission, so that users can easily read the message?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author xnau webdesign

    (@xnau)

    This is not too easy to do, you’ll need to understand how HTML anchors work and you’ll need to do a little coding. If you’re comfortable with that, here’s how you do it:

    It will require a custom template for your signup shortcode. You add a little bit of javascript to the template that adds the “anchor” that the page will return to after the signup form is submitted.

    The “anchor” tells the page where to scroll to, so you need to set up a target on the page which is where the page will scroll to after the signup form is submitted. The target is usually a heading, which is given an HTML anchor value. (You’ll see this in the “advanced” pane in the block editor when the heading is selected)

    The example I’m providing uses the the word “target” as the anchor. This means that you need to have a heading with an HTML anchor of “target” so the page has a place to scroll to…normally, this will be jiust aboive the [pdb_signup] shortcode.

    Here is an example javascript that adds the anchor to the “thanks page” value. when the signup frm is sub,itted, it will scroll to the heading you set up.

    <script>
    jQuery(document).ready(function($){
      var thanks = $('.pdb-signup [name=thanks_page]');
      thanks.val(thanks.val()+'#target');
    });
    </script>
    Thread Starter mmagnani

    (@mmagnani)

    Thanks!
    The following snippet did the trick with standard template and same page Thanks Message:

    jQuery(document).ready(function(){
    	if(jQuery('.pdb-thanks').length) {
    		jQuery(window).scrollTop(jQuery('.pdb-thanks').offset().top);
    	}
    });
    Plugin Author xnau webdesign

    (@xnau)

    great, that’s a smart way to do it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Scroll to signup form after submission’ is closed to new replies.