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

M

Matthew Sims

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top