This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Two Submit buttons in JSP Page 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 JSP Page" Watch "Two Submit buttons in JSP Page" New topic
Author

Two Submit buttons in JSP Page

krishna Mohan Athota
Greenhorn

Joined: Jul 18, 2009
Posts: 10
Hi,

I have one JSP Page with
One Edit Box
Two Submit buttons "Button #1", "Button#2"

If i hit the "Enter" key in keyboard, "Button #1" should fire.
If i keep a cursor pointer in text box, and hit the "Enter" key then "Button #2" should fire.

Can anyone help me different approaches to achieve this solution?

Thank you
Krishna Mohan
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
On the text box's onkeypress event, add a javascript method to trigger the second submit button. I guess that should do it.
vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

krishna Mohan Athota wrote:Hi,

I have one JSP Page with
One Edit Box
Two Submit buttons "Button #1", "Button#2"

If i hit the "Enter" key in keyboard, "Button #1" should fire.
If i keep a cursor pointer in text box, and hit the "Enter" key then "Button #2" should fire.

Can anyone help me different approaches to achieve this solution?

Thank you
Krishna Mohan


How many text boxes you are having ....... the only way you can do it through triggering a JavaScript function when you keep the cursor pointer in text box .in that function set a Boolean then when you press Enter call another JavaScript function which will check the boolean value .... using document.formname.submit(); to submit inside that to submit the page.........

you can check the links for reference ....boolean




VIJINDAS
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60814
    
  65

Nothing to do with JSP. Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: Two Submit buttons in JSP Page
 
Similar Threads
How to specify default button in JSF
Submitting with "Enter" from textbox where there are several submit buttons on form
How to set default image button
Submit button problem
enter key events in a page containing 2 or more than 2 buttons