Submit by hitting enter not clicking the button
Moderator: General Moderators
-
scubadiveflorida
- Forum Newbie
- Posts: 10
- Joined: Wed Oct 29, 2003 9:53 am
Submit by hitting enter not clicking the button
I have built a form and when you type in the data in the text field then click submit, it works fine. But... when I type in the data in the text field then hit enter it fails. Is there a way I can make enter do the same thing as clicking the submit button? Thanks.
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
Re: Submit by hitting enter not clicking the button
What exactly is failing?scubadiveflorida wrote:I have built a form and when you type in the data in the text field then click submit, it works fine. But... when I type in the data in the text field then hit enter it fails. Is there a way I can make enter do the same thing as clicking the submit button? Thanks.
If, on your action page, you are looking for say a value in $_POST["mysubmitbutton"], it'll come up as empty if you pressed ENTER.
If you just mean that ENTER fails to submit the form, then you can do this:
In the text field, you can add the attribute onKeyPress to run a JavaScript function that sees whether the key pressed was ENTER then if so, document.form.submit(). I don't have any script handy for this event handling.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK