Form action attribute
Definition and Usage
action
Set or return the value of the action attribute in the form.
The HTML action attribute specifies where to send the form data when submitting the form.
See also:
HTML Reference Manual:HTML <form> action Attribute
Example
Example 1
Change the action URL of the form:
document.getElementById("myForm").action = "/action_page.php";
Example 2
Returns the URL that sends the form data when submitting the form:
var x = document.getElementById("myForm").action;
Note:In the above example, Internet Explorer 7 and earlier versions return "/action_page.php", while IE 8+, Firefox, Opera, Chrome, and Safari return the entire URL: "https://www.codew3c.com/action_page.php".
Syntax
Return the action attribute:
formObject.action
Set the action attribute:
formObject.action = URL
Attribute value
Value | Description |
---|---|
URL |
Specifies where to send the form data when submitting the form. Possible values:
|
Technical Details
Return Value: | A string value representing the target URL for sending form data when submitting the form. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |