Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait for Form to Submit

Status
Not open for further replies.

thankgodfortektips

Programmer
Dec 20, 2005
95
KY
Hey all,

I have an asp page which inserts records into a db. I have a flag that will not allow the insert until it is set to 1. I also have drop down boxes which will submit the form - which in turn fills in different information on the form dependant on what was selected in the drop down (but the record is not inserted until the flag is set to 1).

After the submit, the page jumps back up to the top of the page, which is confusing for the user. What I want is after the submit move the focus to a lower field.

The problem I am having is that the below function works, but the focus is moving to fast... therefore, the focus will move to the right field, but then the time delay on the submit makes the page return to the top.

Is there a way to make the function below wait for the submit to finish?

The drop down boxes call:

function GetAddressInfo(){
//submit the form
document.form1.submit();
//move focus down to the round trip field
var the_form = document.forms["form1"];
the_form.RoundTrip.focus();
}

Thanks in advance!
 
Form submittal doesn't get 'acknowledged', it only causes an HTTP request to be sent. What the server does with that, typically, is return a page, just like any other request - unless you're strict with your server, most pages requests don't care whether you issue a GET or POST request for any given page. Presumably, in your case, you are submitting your forms to the same page address, and it is this that causes your page to 'jump to the top'.

It is possible to achieve what you intend by, for instance, returning a page which if form submittal has been successful contains an onLoad function to perform your focus jump, or by submitting a duplicate form held in an iframe and thus not unloading your primary page at all, or any number of other technical dodges, but the basic suggestion you are asking for simply doesn't work.

 
I'd bow, but you'd not see me perform anyhow. The obfusticated code forum lives elsewhere ... sometimes clarity can be helpful too.

Admittedly, I'm appalled at the number of grammatical flaws I can spot in that post now that I read it through. Obviously it's time to go and hang myself for a while for crimes against the poor defenseless language again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top