trying to work with onfocus

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    #1

    trying to work with onfocus

    Here is the layout of my form from left to right, from top to down.

    - buttonA, buttonB, buttonC
    - textbox, textbox, textbox
    - buttonXXX

    After the user types in the textboxes and press enter (with the cursor still
    in one of the textboxes), buttonXXX should be pressed by default.(the user
    is too lazy to take the cursor over to buttonXXX and click).

    The problem is the top/left most button (button A) gets pressed which annoys
    them to death. So I tried to do this.

    In the bottonA's onfocus event handle-
    document.forms[0].elements['buttonXXX'].focus() .

    Result: ButtonXXX receives focus alright, but the code for buttonA still
    executes! Any help would be greatly appreciated.





  • NJSG

    #2
    Re: trying to work with onfocus

    Check if buttonA is a standard button (<input type="button" ...>)
    and if butonXXX is a default/submit button (<input type="submit"
    ....>).
    The code to be executed on clicking "buttonXXX" should be in a
    function, suck as buttonXXX_click . See if the "action" attribute for
    the "form" element is "buttonXXX_clic k()" (<form
    action="buttonX XX_click()" ...>).

    Hope this help,
    Nuno Silva (aka NJSG)

    === - ===
    My english isn't very good, because it isn't my first language. If you
    found any mistake (or have problems understanding the post), tell me.
    === - ===
    I have a 33.3 kbps Internet Dial-Up Connection.
    Please wait by my replies with patience.

    David escreveu:[color=blue]
    > Here is the layout of my form from left to right, from top to down.
    >
    > - buttonA, buttonB, buttonC
    > - textbox, textbox, textbox
    > - buttonXXX
    >
    > After the user types in the textboxes and press enter (with the cursor still
    > in one of the textboxes), buttonXXX should be pressed by default.(the user
    > is too lazy to take the cursor over to buttonXXX and click).
    >
    > The problem is the top/left most button (button A) gets pressed which annoys
    > them to death. So I tried to do this.
    >
    > In the bottonA's onfocus event handle-
    > document.forms[0].elements['buttonXXX'].focus() .
    >
    > Result: ButtonXXX receives focus alright, but the code for buttonA still
    > executes! Any help would be greatly appreciated.
    >
    >
    >
    >
    >[/color]

    Comment

    Working...