Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1658
  • Last Modified:

add two submit button to form

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
master_programmer
Asked:
master_programmer
1 Solution
 
ysnkyCommented:
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
 
gamebitsCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now