Categories
HTML

How to make an HTML form with two submit buttons and two “target” attributes?

Spread the love

Sometimes,. we want to make an HTML form with two submit buttons and two "target" attributes.

In this article, we’ll look at how to make an HTML form with two submit buttons and two "target" attributes.

How to make an HTML form with two submit buttons and two "target" attributes?

To make an HTML form with two submit buttons and two "target" attributes, we add the formaction attribute to each button.

For instance, we write

<!DOCTYPE html>
<html>
  <body>
    <form>
      <input
        type="submit"
        formaction="firsttarget.php"
        value="Submit to first"
      />
      <input
        type="submit"
        formaction="secondtarget.php"
        value="Submit to second"
      />
    </form>
  </body>
</html>

to set the formaction attribute of each button to the URL to make the request to when we click on it.

Conclusion

To make an HTML form with two submit buttons and two "target" attributes, we add the formaction attribute to each button.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *