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!

Setting focus on page load 2

Status
Not open for further replies.

boatdrinks

IS-IT--Management
Jun 18, 2004
51
US
I have this in the body tag of my asp.net page

onLoad="javascript:document.form1.insertfirstname.focus()"

When the page loads I get the error

document.form1.insertfirstname is null or not an object

What can I do about this?
 
You can check the spelling and capitalization of your form name and field name, and you can change the code to this:

Code:
onload = "document.forms['form1'].elements['insertfirstname'].focus();"

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
1. You don't need the [tt]javascript:[/tt] prefix to onload.
2. Try using [tt]document.forms['form1'].elements['insertfirstname'].focus();[/tt]
3. Are you sure the names are correct?
4. What browser are you using?

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
insertfirstname had capital letters, I didn't know it was a problem

Thanks everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top