Results 1 to 4 of 4

Thread: Submit button focus

  1. #1

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Question 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
    Mark
    -------------------

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    have you tried messing with the tabindex (or is it taborder? ) attribute for the form elements? You might have some luck with it...
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    I tried playing with the taborder but it didn't help.

    I think it's probably one of those non-standard IE features
    Mark
    -------------------

  4. #4
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width