How to submit a form using a button outside the form tag with HTML?

Spread the love

Sometimes, we want to submit a form using a button outside the form tag with HTML.

In this article, we’ll look at how to submit a form using a button outside the form tag with HTML.

How to submit a form using a button outside the form tag with HTML?

To submit a form using a button outside the form tag with HTML, w ecan set the form attribute of the submit button.

For instance, we write

<form id="myform" method="get" action="something.php">
  <input type="text" name="name" />
</form>

<input type="submit" form="myform" value="Update" />

to add a form and a submit button/

Then we set the form attribute of the submit button to the ID of the form element to make the submit button submit the form with the ID myform.

Conclusion

To submit a form using a button outside the form tag with HTML, w ecan set the form attribute of the submit button.

Leave a Reply

Your email address will not be published.