How to add two submit buttons in one form with HTML?

Spread the love

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.

Leave a Reply

Your email address will not be published.