Form method attribute
Definition and usage
method
Attribute settings or return the value of the method attribute in the form.
The HTML method attribute specifies how form-data is sent (form-data is sent to the page specified by the action attribute).
See also:
HTML reference manual:HTML <form> method attribute
Instance
Example 1
Change the method used to send form data:
document.getElementById("myForm").method = "post";
Example 2
Return the method used to send form data:
var x = document.getElementById("myForm").method;
Syntax
Return the method attribute:
formObject.method
Set the method attribute:
formObject.method = get|post
Attribute value
Value | Description |
---|---|
get | Attach form data to URL: URL?name=value&name=value (default). |
post | Send form data as an HTTP POST transaction. |
Technical details
Return value: | String value, indicating the HTTP method to be used for submitting the form ("get" or "post"). |
---|
Browser support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
Note:If the method attribute is undefined (default), Chrome, Internet Explorer/Edge, Firefox, and Opera will return "get
However, Safari does not return any content.