Page 1 of 1

Formbuilder Anchor Link

Posted: Tue Aug 23, 2016 4:59 pm
by mr.bacan
Hi everyone, I'm working on a form which is located on the end of the page. Once the user fills the form and hit the send button, if it has errors the page loads again but at the top, so user has to scroll down all the way to the form in order to see the error message. I've tried applying a "Form Submission JavaScript" with this:

Code: Select all

onclick="location.href='#contact'"
but when page refreshes the anchor link is not applied.

The same happens when the user successfully sends the form, the page loads on top so user has to scroll down to see the "Submission Template".

Thanks in advance for any help on this.

Re: Formbuilder Anchor Link

Posted: Tue Aug 23, 2016 6:12 pm
by calguy1000
I would use some simple jquery to append the #fragment to the form submission URL. Either on load or on submit.

Something like this (untested) should be close. assumes jQuery.

<div id="something">
<a id="anchor"></a>
{FormBuilder form='something'}{* or put the wrapper div in the form template *}
</div>

$(document).ready(function(){
$('#something > form').submit(function(){
var action = $(this).attr('action');
$(this).attr('action',action+'#anchor');
});
});

Re: Formbuilder Anchor Link

Posted: Tue Aug 23, 2016 6:26 pm
by Rolf
Try something like:

Code: Select all

{FormBuilder|replace:'http://www.website.com/page':'http://www.website.com/page#contact' form=... }

Ps. I use similar in http://www.cmscanbesimple.org/blog/addi ... ook-module

[SOLVED] Formbuilder Anchor Link

Posted: Tue Aug 23, 2016 6:53 pm
by mr.bacan
Thanks Calguy and Rolf, both suggestions worked, but I have to say that Rolf's version was straight to the point and did the trick immediately without having to add more code to my template.

Thank you both, I've learned something new today.