rsammy Posted April 11, 2008 Share Posted April 11, 2008 i am working on a php screen. there is just one field in this screen and then a 'submit' button. i enter some info on the screen and hit enter(focus is still on the text field). how do i submit the form without tabbing to the submit button? is there a way to do this? this is my field: <tr> <td width="161"> <div align="right"><font class="inputLbl">Location Name: </font></div></td> <td colspan="2"> <input name="orgname" type="text" class="txtboxLarge" id="orgname" onBlur="javascript:changeCase(document.addNewLoc.orgname);"> <font class="redTxt">*</font> </td> </tr> <tr> <td width="161"> </td> <td colspan="2"> <input class="sbttn" type="submit" name="action" value="Submit"> </td> </tr> and this is what im doing when i submit the form: <td width="456" align="left" valign="top"> <form action="addlocation.php" method="post" name="addNewLoc" id="addNewLoc" onSubmit="return validate()"> Quote Link to comment https://forums.phpfreaks.com/topic/100723-enter-button-on-screen/ Share on other sites More sharing options...
benphp Posted April 11, 2008 Share Posted April 11, 2008 You could use a javascript onkeydown event. Quote Link to comment https://forums.phpfreaks.com/topic/100723-enter-button-on-screen/#findComment-515153 Share on other sites More sharing options...
rsammy Posted April 11, 2008 Author Share Posted April 11, 2008 You could use a javascript onkeydown event. how? Quote Link to comment https://forums.phpfreaks.com/topic/100723-enter-button-on-screen/#findComment-515192 Share on other sites More sharing options...
benphp Posted April 12, 2008 Share Posted April 12, 2008 Now that I think of it, that won't work, because it would submit it on any key down. I think this is what you want: http://www.cs.tut.fi/~jkorpela/forms/enter.html Quote Link to comment https://forums.phpfreaks.com/topic/100723-enter-button-on-screen/#findComment-515567 Share on other sites More sharing options...
rsammy Posted April 14, 2008 Author Share Posted April 14, 2008 thanx ben! im tryin it out, does not seem to work. i need to use this feature along with this one: <td width="456" align="left" valign="top"> <form action="addlocation.php" method="post" name="addNewLoc" id="addNewLoc" onSubmit="return validate()"> when submit button in clicked, validate() javascript function in executed(this function validates for blank field and returns an error message when field is left blank). i still need to do this along with the new feature (hitting enter should submit the form). hope im clear with my requirement. thanx once again. help here will be really really great. Quote Link to comment https://forums.phpfreaks.com/topic/100723-enter-button-on-screen/#findComment-516979 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.