Default input

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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.


Re: Default input

Zack wrote:

Quoted text here. Click to load it

Normally your question would be answered by saying that you specify the
default value for a text input field in the value="..." attribute.

Quoted text here. Click to load it

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(),

Site Timeline