Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two submit buttons in a form?

 
Mallik Avula
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic