Form with multiple submits, but pressing enter focuses on the wrong button

Discussion in 'Javascript' started by Matthew Sims, Mar 4, 2004.

  1. Matthew Sims

    Matthew Sims Guest

    Hello,

    I have a form with 4 submits, each submit performs a different task
    using PHP.

    One of the submits is the real submit button and when my user enters
    their password in the passwd text box I would like this particular
    submit to activate when the user presses the enter key on the
    keyboard.

    Currently, the 1st submit button in the order is defaulted when
    pressing the return key and that's not what I want.

    Javascript is not my forte and after an hour of researching online
    this is the closest to what I can find...though it doesn't work.

    ****************

    <head>
    <script language="JavaScript" type="text/javascript">
    function showKeyValue(evt) {
    var keyValue;
    keyValue = window.evt.keyCode;
    if (keyValue == 13) {
    javascript:document.formWalkthrough.submit.submit();
    }
    return false;
    }
    </script>
    </head>

    <body>
    <form method="post" name="formWalkthrough" action="index_walk.php">
    ....
    <input type="submit" name="editmode"
    style="font-size:12px;width:110px;" value="Edit Mode">

    <input type="submit" name="shiftturnover"
    style="font-size:12px;width:110px;" value="To Shift Turnover">

    <input type="submit" name="view" style="font-size:12px;width:110px;"
    value="View Reports">

    <input type="password" onKeyPress="showKeyValue(event)"
    name="enterPasswd" size="13">

    <input style="margin-top:5px;" type="submit" name="submit"
    value="Submit">
    *** This is the submit I want activated when pressing enter from the
    enterPasswd text field above ***
    </body>

    So what am I doing wrong?

    ~~
    Matt
    Matthew Sims, Mar 4, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Philip Townsend

    button focus and pressing enter

    Philip Townsend, Aug 14, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    8,742
  2. Philip Townsend

    button focus and pressing enter

    Philip Townsend, Aug 25, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,224
    Philip Townsend
    Aug 25, 2003
  3. Dan Brussee

    Default button - pressing Enter

    Dan Brussee, Feb 19, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    442
  4. Neo
    Replies:
    2
    Views:
    3,182
    bruce barker
    May 11, 2004
  5. albert kao
    Replies:
    1
    Views:
    1,995
    marisa lee
    Apr 10, 2010
Loading...

Share This Page