Solved

add two submit button to form

Posted on 2007-12-02
2
1,652 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS style formatting? 2 31
Website checklist for browser compatibility? 2 37
Fix Form size HTML 16 30
links not working 2 25
This article discusses four methods for overlaying images in a container on a web page
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

740 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