*
The moose likes HTML, CSS and JavaScript and the fly likes Form submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Form submit" Watch "Form submit" New topic
Author

Form submit

Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Hi, I have a question on submitting a form in a JSP. I have a form that contains 2 submit buttons and a text field. If a user enters a value in the text field and then presses the Enter button on the keyboard, the form should get submitted. My question is which submit is used since there are two buttons? Does the first submit button get used? Can I set a default submit button?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Nothing to do with JSP per se. Moved to the HTML/Javascript forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Why two submit buttons? If only one is to have submit semantics, make it the submit button and leave the other without submit behavior.
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Good question. It is because we are using a third party vendor's tool which abstracts all of the Form and form elements. For example, instead of being able to code a submit or plain button input, we use a graphical widget to drop a button into a template. The button widget is always of type "submit". I have to use a "View Source" in order to see the actual html that gets produced.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

When a tool creates more problems than it solves ...

If there's no way to control it, you may just have to try it out and see how it works for you. Be aware that the behavior may be browser-specific.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form submit
 
Similar Threads
HTML Form
a question about dynamically form
Delegating requestes to different servlets based on the submission.
multiple submit buttons
"enter key" button focus ?