method property (form)
Specifies or returns 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 property, which specifies the target URL of sending.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: method |
Possible values:
String that sets or retrieves the type of the transfer.
One of the following values:
Appends the (name, value) pairs to the target URL specified by the action property. 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. | |||||||
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 property 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?
|
Example HTML code 2:
This example illustrates the use of the method property:
|
||||
<head> <script type="text/javascript"> function GetMethod () { var form = document.getElementById ("myForm"); alert (form.method); } </script> </head> <body> Send the form, and see the location bar. <form id="myForm" 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> <button onclick="GetMethod ();">Get method type!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
Related pages:
External links:
User Contributed Comments