View Full Version : Tricky Problem with Anchors and page reloads

Dean Forant
07-09-2004, 08:18 PM
Hey People:

I have a little problem that has been driving me nutty..

I have a form that the user enters a vaule from the dropdown menu and depending on what they select the form submits to itself and the value is queryed against a database to generate a dependant dropdown for the next field.

this all works fine however.. seeing that the page is a little long and as the user gets to the middle part of the form when the page reloads the user is at the top of the page and he needs to scroll down to finish filling the form out..

what I wonder if I can do is every time the page is reloaded automatically go to the beggining of the form so the user doesn't have to scroll down echtime to finish filling the form out.

I tried setting an anchor and using window.location.has = 'NameofAnchor' but it doesn't seem to work.

heres my Javascript functions right now.

<script Language = "JavaScript">

function selItem(SelMetal,SelElast,SelSealType,SelModel,SelSizeType,SelInchSize,SelMetricSize)
{ document.location.href="BuildPart.asp?SMetal="+SelMetal+"&SElast="+SelElast+"&SealType="+SelSealType+"&SModel="+SelModel+"&SizeType="+SelSizeType+"&SInch="+SelInchSize+"&SMetric="+SelMetricSize;

This sets up the query strings to check to see if a field was filled and if it was I have some ASP code to query the database to poulate the next feild

this is the event code for the first form element that calls the function.. theres other events calling the selItem function and the variables are set accordingly because I check wheather the veriable is undefiened or not.. (this tells asp that if its undefined that the user hasn't picked anything in that element yet)

like I said all that codes ok.. I just need to have the page go to an anchor automatically everytime it reloads with the new querystring variables..

any suggestions..
Thank you

07-09-2004, 08:44 PM
aName = new Array("anchor1","anchor2");
function goAnchor(aName){
window.location.href="#" +aName;




07-09-2004, 08:46 PM

07-12-2004, 11:55 AM
Add the anchor in the location.href part