The “formaction” Attribute in HTML5
November 3, 2018
Using HTML5’s “formaction” attribute, you can have an unlimited number of Submit buttons in a Web form and have each button link to a different destination.
Here’s an example:
HTML
x
13
13
1
<form action="process_main.php" method="get">
2
<label for="fname">
3
First name: <input type="text" id="fname" name="fname">
4
</label>
5
<br>
6
<label for="lname">
7
Last name: <input type="text" id="lname" name="lname">
8
</label><br>
9
<input type="submit" value="Default Submit">
10
<input type="submit" formaction="process1.php" value="Submit to Page1">
11
<input type="submit" formaction="process2.php" value="Submit to Page2">
12
<input type="submit" formaction="process3.php" value="Submit to Page3">
13
</form>
Test Live in JSFiddle:
Want to learn more? Christian recommends: