Formbuilder Anchor Link

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
mr.bacan

Formbuilder Anchor Link

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Formbuilder Anchor Link

Post 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');
});
});
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Formbuilder Anchor Link

Post 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
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
mr.bacan

[SOLVED] Formbuilder Anchor Link

Post 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.
Locked

Return to “Modules/Add-Ons”