Back to Content

HTMLButtonElement: formMethod property

files/en-us/web/api/htmlbuttonelement/formmethod/index.md

latest1.2 KB
Original Source

{{APIRef("HTML DOM")}}

The formMethod property of the {{domxref("HTMLButtonElement")}} interface is the {{Glossary("HTTP")}} method used to submit the {{HtmlElement("form")}} if the {{HTMLElement("button")}} element is the control that submits the form. It reflects the value of the <button>'s formmethod attribute.

The value overrides the {{domxref("HTMLFormElement.method", "method")}} property of the {{domxref("HTMLFormElement")}} interface if the form is submitted via the button. This property can be retrieved or set. If set with an empty or invalid value, the invalid default value is "get". If not set at all, the value is the empty string ("").

Value

A string; "post", "get", "dialog", or "".

Examples

js
btnEl.formMethod = "post";

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("HTMLButtonElement.formAction")}}
  • {{domxref("HTMLButtonElement.formEnctype")}}
  • {{domxref("HTMLButtonElement.formNoValidate")}}
  • {{domxref("HTMLButtonElement.formTarget")}}
  • {{domxref("HTMLFormElement.method")}}
  • Sending form data