THE WORLD'S LARGEST WEB DEVELOPER SITE

Form action Property

❮ Form Object

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:
  • An absolute URL - points to another web site (like action="http://www.example.com/example.htm")
  • A relative URL - points to a file within a web site (like action="example.htm")


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;

The result of x will be:

https://www.w3schools.com/action_page.php
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