Sometimes, we want to add two submit buttons in one form with HTML.
In this article, we’ll look at how to add two submit buttons in one form with HTML.
How to add two submit buttons in one form with HTML?
To add two submit buttons in one form with HTML, we set the formaction
attribute.
For instance, we write
<form>
...
<button type="submit" formaction="/action_one">First action</button>
<button type="submit" formaction="/action_two">Second action</button>
</form>
to add 2 buttons that has formaction
set to different URLs.
Then when we click on each, they’ll make a request to the formaction
URL value.
Conclusion
To add two submit buttons in one form with HTML, we set the formaction
attribute.