HTML <button> Tag with the 'form' Attribute
<form id="myForm" action="/resources/html-forms-action.cfm">
<!-- ...form contents... -->
</form>
<button form="myForm">
Submit Form
</button>
In the above example we add the form
attribute to a button control. We also add the actual <form>
element that the button is using.
About the form
Attribute
The form
attribute allows you to specify the ID of a form to which this control belongs. This allows you to use the <button>
element without having to nest it within <form>
tags.
If this attribute is used, its value must be the ID of a form element in the element's owner.
About the <button>
Element
The <button>
element creates a button control in an HTML document.
Any contents of the <button>
element appears on the button.
The <button>
element can be associated with a form or stand alone by itself (in such case it could have JavaScript attached via the onclick
attribute) to make the button actually do something.