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

Cursor placement on a form 1

Status
Not open for further replies.

SuperComputing

IS-IT--Management
Oct 11, 2007
57
US
I have a single entry form on an .asp page that reads in a barcode number and queries a database and returns the details for that item.

When the page first loads, and when it reloads after the query, I need the cursor to be automatically placed into the input for the form.

Is there an easy way to do this, or will I have to use java?

Thank You!
 
Use the onload property in your body tag.

[tt][blue]<body onload="document.form.password.focus()">[/blue][/tt]

Of course, you'll have to change it a bit to accomodate your page.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I tried several variations of:

<body onload="document.form.password.focus()">

and nothing worked. So I did a little more reading and realized that I had my field named, but not my form. So I changed:

<form action="results.asp" method="post">
<input type="text" name="upc">

to:

<form name=form action="results.asp" method="post">
<input type="text" name="upc">
and
<body onload="document.form.upc.focus()">

and everything is working perfectly.

Thank you again for your help!
 
Try not to name the form "form", would you?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top