-
Submit button focus
Have a play with this code:
Code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<form><INPUT name=text1><br>
<INPUT name=text2><br>
<INPUT name=text3><br>
<INPUT type='submit' value="Button 1" name=button1>
<INPUT type='submit' value="Button 2" name=button2>
</form>
</BODY>
</HTML>
When you position a cursor in one of the text boxes, button 1 gets focus although the taborder remains intact
i.e. you can still tab from text1 to text2
How can I make button 2 get focus instead?
Doing this:
Code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<form name=f1><INPUT name=text1 onfocus="document.f1.button2.focus()"><br>
<INPUT name=text2 onfocus="document.f1.button2.focus()"><br>
<INPUT name=text3 onfocus="document.f1.button2.focus()"><br>
<INPUT type='submit' value="Button 1" name=button1>
<INPUT type='submit' value="Button 2" name=button2>
</form>
</BODY>
</HTML>
messes up the tab order :(
-
have you tried messing with the tabindex (or is it taborder? ;) ) attribute for the form elements? You might have some luck with it...
-
I tried playing with the taborder but it didn't help.
I think it's probably one of those non-standard IE features :(
-
Its tabindex (just had a look ;) )
http://www.w3.org/TR/html4/interact/...html#h-17.11.1
Not sure really :( If you change onfocus to onmousedown then when you click the element button 2 gets focus which is not what you want really.
The problem is, if another element gets focus using the onfocus event of another element then the tabbing order isnt going to work.
Code:
<HTML>
<BODY>
<form name=f1>
<INPUT name=text1 onmousedown="document.f1.button2.focus()"><br>
<INPUT name=text2 onmousedown="document.f1.button2.focus()"><br>
<INPUT name=text3 onmousedown="document.f1.button2.focus()"><br>
<INPUT type='submit' value="Button 1" name=button1>
<INPUT type='submit' value="Button 2" name=button2>
</form>
</BODY>
</HTML>