Default input

Z

Zack

How do I set an input to be default? I have a search engine but to input
boxes above it and would like search box selected by default.

Thanks,
Zack (e-mail address removed)
 
J

Jukka K. Korpela

Zack said:
How do I set an input to be default?

Normally your question would be answered by saying that you specify the
default value for a text input field in the value="..." attribute.
I have a search engine but to input
boxes above it and would like search box selected by default.

Apparently, you meant to ask how to make a text input field _focused_
when a page is entered.

The short answer is: Don't.

The longer answer is: You shouldn't, because the user may enter some
input into the field _before_ your client-side script manages to focus
on it. (There's no other way to focus on it than client-side scripting.)
Now imagine yourself typing "foobar" and having just "bar" entered,
since after you had typed "foo", the field was focused, thereby
selecting the text in it, and then the characters "bar" _replaced_ the
old content.

If you _still_ want to do that, use the JavaScript function onfocus(),
see http://www.cs.tut.fi/~jkorpela/forms/javascript.html#focus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top