giving form input bos focus

N

new Karoo

Hi

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.
 
B

brucie

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.
 
K

Kris

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.
 
B

brucie

In post <[email protected]>
Jacqui or maybePete said...

Here's an example page that I think sets focus without those problems:
http://www.porjes.com/ng/ - comment and criticism welcomeish.

focus moves if i don't start typing straight away when the page is
cached. if i'm fast i can click the field i want and type before focus
moves. i still don't see the point of using it in any case. whats so
wrong with letting the visitor fill the form out how they want instead
of second guessing what the visitor wants?
 
J

Jukka K. Korpela

Jacqui or (maybe) Pete said:
Even bloody google does it

Search engine interfaces are rather special. When the _only_ content of
a page is a search form, then a case can be made in favor of automated
initial focus. Even this has some problems though, as Brucie mentioned.
But the real problems begin when people imitate the idea on their own
pages where a form is just a minor ingredient. Automatic initial
focusing implies that tabbing does not start at a reasonable position.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top