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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set focus on a textbox , after form.submit ?

Status
Not open for further replies.

snr

Programmer
Oct 8, 2001
78
0
0
US
I have a form , where for some reason I am submiting it, with action = &quot;<%=request.servervariables(&quot;script_name&quot;)%>&quot;
i.e I am giving the self script name.
It is working just fine. But the problem is , after it submits , and returns back , I want to set the focus on a particular text box , which is not happening.
i.e
document.order.submit()
docnument.order.qty.focus()
where order is my form name & qty is a form text box name.


Thanks

 
in your head tag write this

<script language=&quot;JavaScript&quot;>
document.order.qty.focus()
</script>
 
I tried ...... it is giving error as
document.order.qty is not an object.

Shall I write this code in a function , and call it from a vbscript Sub , where I am submitting the form ?

The problem is I am doing this kind of submit more than 3 times in my script. Each time depending on the text field, where I am submiting , I have to decide the location of next focus...........

What is the solution ?

Thanks
 
try to write this 3 javascript lines before you close the form!!!



<script language=&quot;JavaScript&quot;>
document.order.qty.focus()
</script>
</form>
 
I can see the cursor going to qty field , but is disappears.
Can you suggest any other option ?
 
YOu need to abstract that into a function, and then call it onLoad:

<script language=&quot;JavaScript&quot;>
function setFocus(){
document.order.qty.focus()
}
</script>
<body onLoad=&quot;setFocus();&quot;>
penny1.gif
penny1.gif
 
Nope !!!!!!!!!!! :-(

it is still not working !
 
Then there must be something else going on...

You said it goes there, and then disappears... so something else must be stealing the focus.
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top