The “formmethod” attribute of the input element specifies the HTTP method for transmitting form-data to the action URL.
Crucially, this attribute takes precedence over the “method” attribute of the <form> element.
The “formmethod” attribute is compatible with the following input types: submit and image.
Form data can be dispatched either as URL variables (method=”get”) or as an HTTP post transaction (method=”post”).
Points regarding the “get” method:
Points regarding the “post” method:
Example
A form featuring two submit buttons: one transmits the form-data using the “get” method, while the other transmits it using the “post” method.
<form action=”/action_page.php” method=”get”> <label for=”fname”>First name:</label> <input type=”text” id=”fname” name=”fname”><br><br> <label for=”lname”>Last name:</label> <input type=”text” id=”lname” name=”lname”><br><br> <input type=”submit” value=”Submit using GET”> <input type=”submit” formmethod=”post” value=”Submit using POST”> </form> |