How to set the focus to a text box?

M

Martin

How can I make it so that the cursor is in a specific text box on a
page when the page first appears in the user's browser?
 
L

Leif K-Brooks

Martin said:
How can I make it so that the cursor is in a specific text box on a
page when the page first appears in the user's browser?

Bad idea. It would probably work well for people who use their mouse for
navigation, but what about keyboard users? Changing the first item
focused will effectively change the tab order of the page, and make
keyboard searching not work
 
M

Michael Wilcox

Leif said:
Changing the first item focused will effectively change the tab order
of the page, and make keyboard searching not work

Well, it probably wouldn't completely disable any keyboard navigation
function, but it would be very inconvenient. I also recommend not doing
this, and I would suggest that if the input is very important and it's
the main focus of the page (like the input box on Google), then define
an accesskey and tabindex which will allow a keyboard navigator to jump
to it quickly.
 
M

Martin

How can I make it so that the cursor is in a specific text box on a
page when the page first appears in the user's browser?

Ok, I got this working like I want. I appreciate the comments but
setting the focus to a specific textbox doesn't seem to mess up
anything. The tab order is unchanged.

In fact, is there some way I can set the tab order?

The page I'm working on is to allow the user to enter some data. I
have a series of textboxes arranged in three columns (in a table). The
focus is set to the first textbox in the first column when the page
loads. Currently, using the tab key moves the cursor across to the 2nd
column, then to the third column and then to the second item in the
first column again and so on (IOW, row by row).

What I would like it to do is go down the first column, then to the
top of the second column and down that one and then to the top of the
3rd column and so on.

Is there any way to control this?
 
B

brucie

in post: <
never assume the visitor will fill in a form in the order you expect or
will wait until the page is completely downloaded before they start to
fill out a form.

its very annoying to be half way through a form and all of a sudden the
focus changes. if the visitor is lucky they'll immediately notice and
wont get too pissed with you for screwing them around.
Ok, I got this working like I want.

great, but no one cares what you want or even like. what do your
visitors want and like? do they want to be filling out a form and
suddenly the focus changes to somewhere else? are they going to like it?
In fact, is there some way I can set the tab order?

if the form is designed properly there is no need to change the tabbing
order.
 
N

nice.guy.nige

While the city slept, brucie ([email protected]) feverishly typed...
in post: <

never assume the visitor will fill in a form in the order you expect
or will wait until the page is completely downloaded before they
start to fill out a form.

its very annoying to be half way through a form and all of a sudden
the focus changes. if the visitor is lucky they'll immediately notice
and wont get too pissed with you for screwing them around.

Aha!!! Not if they use the magical and mysterious
"Look-ma-it-focuses-on-the-field-but-not-if-the-user-has-already-started-usi
ng-another-field-blah-de-blah" script!
http://www.nigenet.org.uk/bits-n-bobs/fieldFocusTest.html (For the OP): This
uses javascript (if it is available and enabled) to set the focus on a
specific field (the first one IIRC), unless the user has already started
using the form, in which case it leaves well alone. There is a slightly
oversize picture to slow the loading down. Start typing in either the second
or third text box, and when the page is loaded you are left well alone.
Otherwise, focus will go to the first box.

Cheers,
Nige
 
B

brucie

in post: <
nice.guy.nige said:

amazing, i must have scrolled past this thread a half a dozen times and
didn't see it. to many pretty shiny things to look at.
 

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

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top