Solved

add two submit button to form

Posted on 2007-12-02
2
1,650 Views
Last Modified: 2012-08-14
hi,
i have a form which has a field such as( text box, radio button), i want to have two submit button labeled "add" and "delete" both will get the form parameter and goes to different jsp pages for example (add.jsp for button"add" and delete.jsp for button"delete") and berform different actions,
how i can modify the action of the form to handle actions in different pages depends on the button that has been clicked??
0
Comment
Question by:master_programmer
2 Comments
 
LVL 9

Accepted Solution

by:
ysnky earned 500 total points
ID: 20390811
for a simple sample;
<script>
function submitForm(F, type) {
	
	var loc = "";
	if (type == 'A')
	  loc = "add.jsp";
	else
		loc = "delete.jsp"; 
		
	F.action=loc;
	F.submit();
}
</script>
<form method=post>
<input type=text name=test value="test">
<input type=button value="add" onclick="submitForm(this.form, 'A')">
<input type=button value="delete" onclick="submitForm(this.form, 'D')">
</form>

Open in new window

0
 
LVL 28

Expert Comment

by:gamebits
ID: 20390928
With php I would have the action set to go to the same page and on that page I would have a switch statement to take proper action action depending on what button has been clicked
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Find out what you should include to make the best professional email signature for your organization.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question