Form action Property
Example
Change the action URL of a form:
document.getElementById("myForm").action = "/action_page.php";
Try it Yourself »
Definition and Usage
The action property sets or returns the value of the action attribute in a form.
The action attribute specifies where to send the form data when a form is submitted.
Browser Support
Property | |||||
---|---|---|---|---|---|
action | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the action property:
formObject.action
Set the action property:
formObject.action = URL
Property Values
Value | Description |
---|---|
URL |
Specifies where to send the form data when the form is submitted. Possible values:
|
Technical Details
Return Value: | A String, representing the URL of where to send the form-data when a form is submitted |
---|
More Examples
Example
Return the URL for where to send the form data when a form is submitted:
var x = document.getElementById("myForm").action;
Try it Yourself »
Note: In the example above, Internet Explorer 7 and earlier versions returns "/action_page.php", while IE 8+, Firefox, Opera, Chrome, and Safari returns the entire URL: "https://www.w3schools.com/action_page.php".
Related Pages
HTML reference: HTML <form> action attribute
❮ Form Object