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

onFocus="select(this);" working or not... 1

Status
Not open for further replies.

effennel

Technical User
Oct 15, 2002
60
CA
Hello,

Here is the code that sets the focus in the text area:

<td>Name: <input type="text" name="name" size=30 onFocus="select(this);"><input type="submit" value=" Send "></td>

Here, I get no focus:

<td>Name: <input type="text" name="name" size=30 onFocus="select(this);"></td>
<td><input type="submit" value=" Send "></td>

Why? How to solve?
Thanks
FNL
 
What do you mean "I get no focus"? Your code *runs* when the field gets focus and selects the text.

Perhaps you could clarify your problem a little ...
 
Sorry for the confusioin my thread has brought.

What I meant, instead of focus, select. I want the cursor to be in the text box as the page is loaded. One less click fo the user.

Thank you
FNL
 
<body onload="document.getElementById('name').focus();">

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Good work!

I test my pages with IE6 = ok, but for NS4.7 the select happens in the Location bar (Address).

Any ways around?

Gracias.
FNL
 
try:

<body onload="document.forms['formname'].elements['name'].focus();">

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Good.

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top