How do you give an input box in a form focus when the page loads so that you
can just start typing without having to click in the box first.
this is a bad thing to do. don't bother implementing it. the visitor
may not wait for the page to finish loading before they start filling
out the form so the focus will jump and they may not notice or they
may not all fill the form out in the order you would expect.
i had a host once that did it for the login page. after filling in the
username and half way through the password all of a sudden the focus
would jump back to the username and i would have to start again. it
was very bloody annoying.[/QUOTE]
I am taking the opportunity to jump in and propose an alternative to the
OT's suggestion. To me it is clear that he wants the visitor to be able
to focus on the field as quickly as possible.
I suggest putting a TABINDEX attribute on the INPUT, with a value that
enables the user to quickly tab to the field, surpassing any links or
form controls that may be in the way.
For instance,
<input type="text" name="search" tabindex="1">
Another (additional) idea is to set an ACCESSKEY on the field. However,
using accesskeys is not a popular thing, since it is heard of that it
can interfere with existing keyboard shortcuts in some browsers. Yet, as
an illustration,
<input type="text" name="search" tabindex="1" accesskey="s">
To make this key combination visible to the user would be good. This
could be a way of doing that.
<label>Search: (<kbd>s</kbd>) <input type="text" name="search"
tabindex="1" accesskey="s"></label>
Using accesskeys differs between OS's and browsers, but generally a
modifier key is used in combination with the specified key. ALT-s,
OPTION-s or CTRL-s. See which one applies.