Latest web development tutorials
 

Form action Property

< Form Object

Example

Change the action URL of a form:

document.getElementById("myForm").action = "form_action.asp";
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:

http://www.w3ii.com/jsref/form_action.asp
Try it Yourself »

Note: In the example above, Internet Explorer 7 and earlier versions returns "form_action.asp", while IE 8+, Firefox, Opera, Chrome, and Safari returns the entire URL: "http://www.w3ii.com/jsref/form_action.asp".


Related Pages

HTML reference: HTML <form> action attribute


< Form Object