The “formaction” attribute in HTML5
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:
- Full-Stack Web Development with Django and Angular 8
- Full-Stack Web Development with Flask
- The DOM in JavaScript, jQuery, AngularJS, and React (Lynda.com).
- The DOM in JavaScript, jQuery, AngularJS, and React (LinkedIn)
- Building JSF Web Applications with Java EE 7 (Lynda.com)
- Building JSF Web Applications with Java EE 7 (LinkedIn)
- Troubleshooting Vue.js (packtpub.com)
- Angular 7 New Features
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