0
I have a very extensive html form with several entries , after making the postback
my page is redirected to the top of the form, postback
return to the page I left ?
0
I have a very extensive html form with several entries , after making the postback
my page is redirected to the top of the form, postback
return to the page I left ?
1
You need to save the value of window.pageYOffset
(document.documentElement.scrollTop
to IE8) and restore as soon as your page loads again.
If you are using jQuery you can do so:
<form id="form1">
....
<input type="hidden" name="scrollto" id="scrollto" value="0" />
</form>
$.scrollTop
in scrollto
at the time the form is sent and already restores the scroll position when the page is loaded.$(function(){
$('#form1').submit(function(){
$('#scrollto').val( $(window).scrollTop() );
});
$(window).scrollTop( $('#scrollto').val() );
});
Browser other questions tagged javascript html
You are not signed in. Login or sign up in order to post.
It didn’t work; My form contains 3 types of registration :Address,contact,vehicle, on the same page ;each form is separated in Divs ,each DIV is part of my javascript function: <script> $(Function () { $("#accordion").accordion(); }); </script> this function splits the form and puts it in Tabs! Separate modules, visually improved a lot but, when I do the Postback it does not continue from the ABA where I stopped , it is redirected to the 1st ABA! What I do????
– Hans Miller
All this in one form?
– André Ribeiro
Not every TAB ,Each Form has its form.
– Hans Miller
Then all you have to do is place the comma-separated Forms ids on the selector (
$('#form1, #form2,....)'
), change theid="scrollto"
forclass="scrollto"
and change the selector#scrollto
for.scrollto
in the code. Remembering that you should add the input to all forms.– André Ribeiro