Input Submit formAction Attribute

Definition and Usage

formAction Sets or returns the value of the formaction attribute of the submit button.

The HTML formaction attribute specifies the URL of the file to be processed when the form is submitted.

The HTML formaction attribute overrides the action attribute of the <form> element. Action attribute.

Comment:In the following example, 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".

Comment:The formaction attribute is a new attribute of the <input> element with type="submit" in HTML5.

See also:

HTML Reference Manual:HTML <input> formaction-attribut

Example

Example 1

Get the URL of the file to be processed when the form is submitted:

var x = document.getElementById("mySubmit").formAction;

Try it yourself

Example 2

Change the URL where the form data is sent to:

document.getElementById("mySubmit").formAction = "/action_page2.php";

Try it yourself

Syntax

Return formAction attribute:

submitObject.formAction

Set formAction attribute:

submitObject.formAction = URL

Attribute value

Value Description
URL

Specifies the URL of the file to be processed when the form is submitted.

Note:This will override the action attribute of the <form> element.

Possible values:

  • Absolut URL - full address of the page (such as href="http://www.example.com/formresult.asp")
  • Relativ URL - pekar på en fil på den aktuella webbplatsen (t.ex. href="formresult.asp")

Tekniska detaljer

Returvärde: Strängvärde som anger vart formulardata ska skickas till URL.

Webbläsarstöd

Numren i tabellen anger den första webbläsarens version som helt stöder detta attribut.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Stöd 10.0 Stöd Stöd Stöd