PDA

View Full Version : how to make pressing enter submit a form?



alexi_dst
08-16-2006, 08:40 AM
I have a form page with some options and a submit button at the end.

I want to make it submit the results not only when it is clicked but also when enter is presses. I saw something similar in Google Preference page where when you choose the options given you can press enter and submit it without clicking on the Save Preference button. Any ideas?

shachi
08-16-2006, 12:10 PM
Try this:



<form name="someform" action="http://somehost.somedomain/somepage.somextension">
<input type="text" name="someinput">
<input type="submit">
</form>

mwinter
08-16-2006, 01:51 PM
I want to make [a form] submit the results not only when it is clicked but also when enter is presses.

That will tend to happen by default: if the input focus is currently on a text box (an input element), pressing the Enter key will submit the form.

Though it is sometimes possible to detect keystrokes and act upon them, that sort of fiddling causes more problems than it solves.

Mike