marmite Posted April 26, 2007 Share Posted April 26, 2007 Hi, Sorry, I know this has been asked many times before, but searching in this forum produces 31 pages...! Can anyone tell me whether I have to use javascript to allow the user to hit enter instead of clicking? Do I need to have the forms in a certain order on the page at all? Very happy to be redirected to another article... Thanks Quote Link to comment Share on other sites More sharing options...
xenophobia Posted April 26, 2007 Share Posted April 26, 2007 function checkkey(e){ var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; if(keycode == 13){ submitform(); } } On your form: <body onKeyPress="checkkey(event);"> Why don't you use '<form>' tags? The form will be post when user hit enter key. Anyway, hope this help you. Quote Link to comment Share on other sites More sharing options...
marmite Posted April 26, 2007 Author Share Posted April 26, 2007 Thanks for this I am using a form.... but hitting-enter-to-submit suddenly stopped working when I made some changes to a different page. I have no idea why ??? <form action="login.php" method="POST" id="login" name="login"> <table width="215px"> <tr><td><img src="images/spacer.gif" width="1" height="55" alt="" /></td></tr> <tr> <td width="7px"></td> <td width="70px">Username:</td> <td width="140px"><input name="username" type="text" class="footer" id="username" size="15"></td> </tr> <tr> <td width="7px"></td> <td>Password:</td> <td><input name="password" type="password" class="footer" id="password" size="15"> </td> </tr> <tr> <td align="center" class="footer" colspan="3"><a href="forgottenpassword.php">Forgotten your password?</a> </td> </tr> <tr> <td> <img src="images/spacer.gif" width="1" height="3" alt="" /> </td> </tr> <tr> <td align="center" colspan="3"><input type="image" src="images/loginbutton.gif" id='loginbutton' name='loginbutton' width="80" height="17"> </td> </tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
marmite Posted April 27, 2007 Author Share Posted April 27, 2007 Thanks for that code, but it hasn't helped. Any other ideas, people? Given that it worked before with no javascript, I suspect there is a non-JS solution (or at least it is a non-JS problem) ??? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 30, 2007 Share Posted April 30, 2007 It will only work without JS if there's a single input field. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.