Reputation: 7288
I have a question, I don't know exactly where to search for or if this question is asked before, so please say so if this is the case.
I have a html form that is submitted to a a php file.
<form name="input" action="formaction.php" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
Is it possible to have two submit buttons, one button will post the form to formaction.php and another button will post the form to anotheraction.php
<form name="input" action="html_form_action.asp" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit to formaction">
<input type="submit2" value="Submit to anotheraction">
</form>
Found a solution
Source: http://www.plus2net.com/html_tutorial/submit-two.php
<form name=f1 method=post action=test5.php>
<input type='submit' value='Open default action file test5.php' onclick="this.form.target='_blank';return true;">
<input type='submit' value='Open test6.html' onclick="f1.action='test6.php'; return true;"> </form>
Upvotes: 0
Views: 111
Reputation: 3628
I don't know what the regular way to do this would be, but the first thing that comes to mind is setting the action value with javascript on button click.
HTML
<form name="input" id=input action="html_form_action.asp" method="get">
<input type="submit" value="Submit to formaction" onclick="document.getElementById('input').setAttribute('action', 'theaction.php');">
There might be much better ways to do this thought.
Upvotes: 1