You are here: Reference > HTML > attributes > method (form)

method attribute (form)

Browser support:
Specifies how the data of a form should be submitted to the server. When the user clicks on the submit button of a form, the data of the named elements in the form will be sent. The data contains the name and the value of the named element.
Use it together with the action attribute, which specifies the target URL of sending.
JavaScript page for this attribute: method. You can find other example(s) there.

Possible values:

String that sets the type of the transfer.
One of the following values:
get
Appends the (name, value) pairs to the target URL specified by the action attribute. The maximum length of a URL is 2048 characters. Do not use this value if the form contains several named elements, or if the value of some elements can be large. Another disadvantage of this way of sending is that the (name, value) pairs are visible in the location bar of browsers.
post
Adds the (name, value) pairs to the body of the request. The size and the count of pairs are not limited. The (name, value) pairs are not visible in the location bar of browsers.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the method attribute:
Send the form, and see the location bar.
<form method="get" action="#URL#">
    <select name="Fruit">
        <option value="Apple">Apple
        <option value="Pear">Pear
        <option value="Peach" selected="selected">Peach
    </select>
    <br /><br />
    <input type="submit" value="Send" />
</form>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content