Button formAction attribute
Definition and usage
formAction
Sets or returns the formAction attribute of the button formaction attributevalue.
The formaction attribute specifies where to send form data when submitting the form. This attribute overrides the action of the HTML form action attribute.
The formaction attribute is only used for buttons with type="submit".
Note:In the following examples, Internet Explorer and Opera 12 (and earlier versions) return "action_page2.php", while Firefox, Opera 15+, Chrome, and Safari return the entire URL: "https://www.codew3c.com/action_page2.php".
Note:formaction attribute Is a new attribute of the <button> element in HTML5.
Instance
Example 1
Return the URL that sends form data when submitting the form:
var x = document.getElementById("myBtn").formAction;
Example 2
Change the formaction attribute value of the button:
document.getElementById("myBtn").formAction = "/action_page2.php";
Example 3
Another example of returning the formAction attribute:
var x = document.getElementById("myBtn").formAction;
Syntax
Return the formAction attribute:
buttonObject.formAction
Set the formAction attribute:
buttonObject.formAction = URL
Attribute value
Value | Description |
---|---|
URL |
Specifies the location to send form data. Note: This will override the action attribute of the <form> element. Possible values:
|
Technical Details
Return Value: | String value indicating the URL to which form data will be sent. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <button> formaction Attribute