HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Form method Property

Form Object Reference Form Object

Example

Change the method for sending form data:

document.getElementById("myForm").method="post";

Try it yourself »

Definition and Usage

The method property sets or returns the value of the method attribute in a form.

The method attribute specifies how to send form-data (the form-data is sent to the page specified in the action attribute).


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The method property is supported in all major browsers.

Note: IE, Firefox, Opera and Chrome return "get" even if no method attribute is defined (this is the default value), while Safari returns nothing.


Syntax

Return the method property:

formObject.method

Set the method property:

formObject.method=get|post

Property Values

Value Description
get Appends the form-data to the URL: URL?name=value&name=value (this is default)
post Sends the form-data as an HTTP post transaction

Technical Details

Return Value: A String, representing the HTTP method used to submit the form (either "get" or "post")


More Examples

Example

Return the method for sending form data:

var x = document.getElementById("myForm").method;

The result of x will be:

get

Try it yourself »


Related Pages

HTML reference: HTML <form> method attribute


Form Object Reference Form Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE