File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes multiple submit buttons on html forms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "multiple submit buttons on html forms" Watch "multiple submit buttons on html forms" New topic

multiple submit buttons on html forms

marcosss kant

Joined: Nov 14, 2005
Posts: 1
Hi, I am building an application that has only one html form, but three submit buttons. I know that forms can only have one possible action, so does anybody know how to have the three buttons? Right now, I have three forms (one for each button) that take exactly the same information, so if you don�t know how to have multiple buttons, do you know how to pass information from one form to another in the same html page?

[ November 14, 2005: Message edited by: Bear Bibeault ]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32819

You can use a javascript function to change the form's action when each button is clicked.

Since this question isn't about the IDE in particular, I'll move it to our JSP forum. Welcome to JavaRanch!

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

The value of the button that was clicked will be sent along with the other form fields.
The value of the other button's won't be sent.

This means that you can branch your code on the server and perform different actions according to which button was pressed.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: multiple submit buttons on html forms
It's not a secret anymore!