It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes Two submit buttons in a form? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Two submit buttons in a form?" Watch "Two submit buttons in a form?" New topic
Author

Two submit buttons in a form?

Mallik Avula
Ranch Hand

Joined: Nov 30, 2006
Posts: 86
Hi All,
I have a form with two submit buttons.
Here user can fill one section details* and click on the button for that section.
Or can fill total form and can click the button for total.

If the user clicks on the buttons, it is fine.

But, if the user press the enter, i should check in which section user pressed enter.
If she press enter in that specific section, i should use the first button which updates that section details
If she press enter in the rest of the page, i should use the second button which updates that section as well as the rest of the page details.

Any help greatly appreciated.


Thanks & Regards<br />Mallik Avula<br />SCJP1.4
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You can capture the key press using the onkeypress event. The enter key has key code of 13.
You can invoke the desired submit button using element.click() property.

Do the math.
Mallik Avula
Ranch Hand

Joined: Nov 30, 2006
Posts: 86
Hi Bauke Scholtz, thanks for the reply.
Here where ever user press enter, the press key code will be 13 only, right?
Then which submit button i can call?

Paul Yule
Ranch Hand

Joined: May 12, 2008
Posts: 229
You can pass 'this' to the method you have fired. It will pass the dom element that triggered it. Check which element that is and if it's relevant to you then do your logic.
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
13, is the ASCII key code for the "Enter" key. So, not just in the sections, but anywhere in the computer, if "Enter" key is pressed, the key code will be 13.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two submit buttons in a form?
 
Similar Threads
How to set a default button in the form
want to implement keylistener
Form submit
"enter key" button focus ?
JSF Questions