Click to See Complete Forum and Search --> : Scrolling to a specific position on a new page after form submission


ssurmi
05-16-2003, 02:39 PM
Hello,

I am trying to load a new page after pressing the submit button and want it to be scrolled to a specific position when loaded.

I know it is very easy to use on the same page by using the window.scrollTo(x,y) function. It is also simple if I try to load a page at the beginning by calling the onload in the body tag:

<body onload = "scrollWindow()">

Just don't know how to do it when I use the submit button and it goes to a new page as:

<form name= "thisForm" action = "http://www.google.com">
<input name ="Submit" value="Go">

The onclick and onsubmit function call doesn't work here since it is going to a whole new page.

Also I need to save the Y cordinate value and send this to the new page.

Any help will be appreciated. Please give me an example if you can.

Thanks in advance

Jona
05-16-2003, 02:51 PM
Are you using POST or GET as your form METHOD?

Also, why would you want to scroll the page after you submit something? It's going to a new page anyways, so what would the point be?

ssurmi
05-16-2003, 03:13 PM
Hi Jonna,

Thanks for your quick reply. I just gave an example there. My actual code looks as follows:

if($oData->sPermission == "COMPLETE"){
echo "<form action='Process.htm?sPId=10&x=".microtime()."' method=post>
<td align=center valign=middle><font size=-1>
<input type=submit name=submit value='Completed'>
<input type=hidden name=sCompleted value='".$x."::".$sReportDataId."'>
</font>
</td>
</form>";
}

It is actually loading the same page. But after submission it gets processed (action='Process.htm?sPId=10&x=".microtime()."') and goes to the top of the same page. Process.htm has only php code in it and inside that file it is reloading the same page again as header("location:ViewRecords.htm?x=".microtime());
I used onclick function along with the submit button but it is not working.

The method I am using is "POST"

Jona
05-16-2003, 03:18 PM
Add some Javascript to your PHP instead. Otherwise it's still reloading the page and clearing the event with onload instead of onclick. So basically you should just add some JS to your PHP code.

khalidali63
05-16-2003, 03:59 PM
I remember some time ago you were suggested a solution here already????

anyways..here is the working example I created...

http://68.145.35.86/skills/javascripts/AfterSubmitLoadSameCoords.html

ssurmi
05-17-2003, 01:59 AM
Hello Khalid,

Thanks for your help. Unfortunately I can not go to the link you sent:
http://68.145.35.86/skills/javascripts/AfterSubmitLoadSameCoords.html

khalidali63
05-17-2003, 09:20 AM
try it again..:D

brendandonhue
05-17-2003, 09:24 AM
How about in process.htm add an anchor where you would like it to scroll to
<a name="anchor1">
and the submit button load
process.html#anchor1