Form method attribute
Definition and usage
method
Attribute setting or returning 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:Atur atribut method <form> HTML
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 method attribute:
formObject.method
Set 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, represents the HTTP method used to submit the form ("get" or "post"). |
---|
Dukungan perambah
Angka di dalam tabel menunjukkan versi paling awal perekap yang menyokong sifat ini.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Dukung | Dukung | Dukung | Dukung | Dukung |
Keterangan:Jika atribut method belum ditakrifkan (default), Chrome, Internet Explorer/Edge, Firefox dan Opera akan mengembalikan "get
Kemungkinan Safari tidak mengembalikan sebarang kandungan.