Results 1 to 3 of 3

Thread: how to make pressing enter submit a form?

  1. #1
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to make pressing enter submit a form?

    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?

  2. #2
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Try this:

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

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by alexi_dst
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •