|
Posted by Jukka K. Korpela on 05/08/06 08:16
Zack wrote:
> 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
Navigation:
[Reply to this message]
|