Is it possible in HTML to add more than one submit button having different actions in a single form?

Showing Answers 1 - 3 of 3 Answers


  • Oct 24th, 2007

Yes it is possible. For each submit button onclick call one javascript function. Get the form id and assign the action url inside the javascript function.

  Was this answer useful?  Yes


  • Jul 17th, 2008

No we cant give two actions for a single form. only one action can be performed

but we can give this in alternate way by using javascript

  Was this answer useful?  Yes


  • Aug 19th, 2009

Yes you can:

in javascript:
<input type="button" onclick="add();" name="sub" value ="add" />
<input type="button" onclick="edit();" name="sub" value ="edit" />

and use
document.getElementById("formname").action = "something.php";

or with PHP:
<input type="submit" name="sub" value="add"> <input type="submit" name="sub" value="edit">

you will have $_POST['sub'] equals "add" or "edit"
you can then use if or switch as you see fit in your server script.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions