• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Two submit buttons in a form?

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic