Form methodProperty
Form Object
Definition and Usage
The method property sets or returns the value of the form's method attribute.
The method property specifies how form data is sent (the form data submission address is specified in the action attribute).
Syntax
formObject.method=value
The method property can have the following values:
| Value | Description |
|---|---|
| get | Appends form data to the URL: URL?name=value&name=value (default) |
| post | Uses the HTTP POST method to submit form data |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the method property
Note:In Internet Explorer, if the method attribute is not defined, it returns "get" (default); other browsers return no value.
Example
Example
Return the method for sending form data:
<html>
<body>
<form id="frm1" action="form_action.html" method="get">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").method);
</script>
</body>
</html>
<body>
<form id="frm1" action="form_action.html" method="get">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").method);
</script>
</body>
</html>
The output result of the above example is:
get
Try it Yourself »
Form Object Other Extensions