The moose likes HTML, CSS and JavaScript and the fly likes determining which form is posted when press enter key Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "determining which form is posted when press enter key" Watch "determining which form is posted when press enter key" New topic
Author

determining which form is posted when press enter key

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
I have two forms on my JSP page. One is a little search box that looks up a bunch of address book IDs that can be used to load a recipient's info on the page, and so far, the only way I've been able to get the user to be able to submit it is to include a specific Search button for that little search box--otherwise, the other form on the page gets submitted.
To clarify, the page displays a recipients and his/her address, and when you have all the info on the page, you can choose to use that address (submitting the main form). Otherwise, you use the small search box to search for the IDs of address book records you already have, and I'd love to make it possible for the user to be able to type an ID in there and be able to just hit Enter instead of clicking on the submit button (however, I'd probably prefer to use Enter to submit the other form if the cursor is outside of that search box form).
Thanks for any help...
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23621

The following code does what you expect. It takes you to google if you press enter while in the first textbox, but javaranch if you press enter while in the second textbox.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
 
IntelliJ Java IDE
 
subject: determining which form is posted when press enter key
 
Threads others viewed
Where to kick this off?
setting up J2EE appln at home?.
Struts 1.2.9 +text areas.
submitting the form on press of 'ENTER'
How to capture enter key?
developer file tools