HTML | Tutorials

David Carr

HTML 5 Submit form - multiple actions with formaction

When working with forms there are often times it would be really handy to be able to submit the form and depending on the button clicked changed the form action the data is posted to. Normally this has not been possible so we find workarounds.

I recently found the need for this again and come across a HTML attribute called formaction which is amazing for this! This attribute allows you to specify the url to post to which when pressed will override the form action attribute.

For instance take this form, by default when the form is submitted the form will be posted to next.html but if the input with formaction=”alt.html” is pressed then the form is posted to alt.html instead.

<form action="next.html" method="post">

 <p><input type="submit" name="altSubmit" formaction="alt.html" value="Go to Alt"></p>
 <p><input type="submit" name="nextSubmit" value="Go to Next"></p>

It’s worth pointing out this only works on IE 10 and above and the latest Chrome, Firefox etc

Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.