Killersites.com Homepage Welcome Guest   |   Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | User List  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 4
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3766 times and has 3 replies Next Thread
Male rridley
Stranger




Joined: Aug 9, 2004
Post Count: 4
Status: Offline
Reply to this Post  Reply with Quote 
first <input> in form not recieving initial focus

I'm having a consistent problem in developing forms.

I have a form on a page will a number of input fields in it as well as a few links on the page before the header that are not in the form. When the form comes up, I have to hit the <tab> key once for the first input to recieve the focus (or click on it with the mouse). If I don't hit the tab key first and just start typing, the browser focus (mozilla) jumps to the link that contains the first letter I type.

I have tried using the "tabindex" attribute, setting the first form <input> to "1" and all others to "0", but it makes no difference. I still have to hit the tab key first.

Any ideas on how to make that first <input> tag recieve the focus by default?

[Aug 15, 2004 8:42:05 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male LSW
Advanced Member
Member's Avatar

USA
Joined: Nov 27, 2003
Post Count: 6285
Status: Offline
Reply to this Post  Reply with Quote 
Re: first <input> in form not recieving initial focus

Tab index is for giving links a priority. Default is the order in which they come in the source code.

also consider that "0" likely cmes before "1". So if you use Tabindex you use 1 for the first field, 2, 3, 4, 5,..... you can't just set the others to "0". If you just set the tabindex 1 and nne others it goes back too default, could be you jump from field 1 to your first Nav. link.

You should consider using accessKeys instead.
[Aug 15, 2004 10:19:56 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male rridley
Stranger




Joined: Aug 9, 2004
Post Count: 4
Status: Offline
Reply to this Post  Reply with Quote 
Re: first <input> in form not recieving initial focus

OK, O'Reilly's book on HTML & XHTML states that the value "0" removes the link from the tabindex order. But what I'm after is to find a way that a link that is not the first link on the page can recieve the focus first thing. I know it can be done because I see web pages all the time that have header links before the first form <input> but that form <input> still gets the first focus, but I can't seem to find out how that first form field gets the focus right off the bat.
[Aug 15, 2004 10:32:54 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male Coretys
Stranger



Japan
Joined: Feb 23, 2004
Post Count: 8
Status: Offline
Reply to this Post  Reply with Quote 
Re: first <input> in form not recieving initial focus

I know only a JavaScript solution:

Use:

<body OnLoad="document.MyFormName.MyInputName.focus();">

and at the very end of the html code (before "</body>") use:

<script language="JavaScript">
document.MyFormName.MyInputName.focus();
</script>

This "double-talk" you need because of the browser differences. Maybe one of each is enough, but right now I don't have time to check it out.

See ya ...

Coretys
[Aug 19, 2004 1:25:34 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread