Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button with Focus? 2

Status
Not open for further replies.

scc

Programmer
Apr 30, 2001
218
US
If a form or page has several buttons, what determines which button has the focus?

This may have two separate answers, depending on if it is a single form or many forms on the page. That's part of what I'm trying to understand.

Thanks for any help on this subject!
 
Generally, the first thing hit by the TAB key is the page address. Then it hits links in the order in which they appear in the code.

You can override that with JavaScript, but it'll surprise your viewers, usually.

This can be an especial pain if you have JavaScript that makes the page, say, hit a server-side database, and then reload, because your cursor focus is back up just-prior-to-the-address-bar. So the trick there is to deliberately place the focus where you want it.

There was a little talk about this is thread216-485313

Cheers,
[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Edward, thanks for posting. I have a couple of questions...

I'm not sure what you mean by "the page address" when you say this is the first thing hit by the TAB key.

Also, I have a text box that has focus, but there is always one button that has a darker border that indicates it as the default. That is what I'm hoping to change... either have a different button be the default or not have the darker border around any of them.

Sorry I'm not completely understanding what you're telling me.

 
By page address, I think Edward is referring to the address bar where is the URL string is entered.

If you are using <input> tags for your buttons, then when type=&quot;submit&quot; becomes your default button. You can either change the type to &quot;submit&quot; for the one button you want to have focus. Or you can set type = &quot;button&quot; for all of them if you don't want any default button.

If it makes sense, I think it is always good to have a default action. Why make me move my mouse when I can just hit 'Enter' to submit my form.

See this link for more info
Hope this helps,
Mickey
 
Mickey,

Thanks for the clarification. I tried to give you a star, but I'm getting an error when doing so. I'll check back later to post the star.

Thanks again!
 
One more somewhat unrelated question... my topic titles are never bold. Most of the other titles are.

Anybody know why? Just curious!
 
By topic titles do you mean the <title> tag? Or <h1><h2> etc. tags?

Posting your code would help out to see what is going on.
Mickey
 
Oh, you mean on this board? Bold means you've not read anything in that string.

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Thanks, Edward... that had been bugging me for some time and I hated to ask!

Another mystery solved!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top