The “formaction” attribute in HTML5

Christian Hur
1 min readNov 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:

<h2>Form with multiple submit buttons:</h2><form action=”process_main.php” method=”get”>
<label
for=”fname”>
First name: <input type=”text” id=”fname” name=”fname”>
</label>
<br>
<label
for=”lname”>
Last name: <input type=”text” id=”lname” name=”lname”>
</label><br>
<input type=”submit” value=”Default Submit”>
<input
type=”submit” formaction=”process1.php” value=”Submit to Page1">
<input
type=”submit” formaction=”process2.php” value=”Submit to Page2">
<input
type=”submit” formaction=”process3.php” value=”Submit to Page3">
</form>

Test Live in JSFiddle:


My online training courses:

My book “Developing Business Applications for the Web: With HTML, CSS, JSP, PHP, ASP.NET, and JavaScript” is available on Amazon and MC Press.

Check out my author page at http://amazon.com/author/christianhur

--

--