HTML DOM Input Submit formAction property

The HTML DOM Submit formAction property is used for setting or getting the formaction attribute value of the form. The formaction property specifies to url where the data is to be sent after clicking on the submit button. The formAction attribute value overrides the action attribute value associated with the <form> element.


Following is the syntax for −

Setting the formAction property −

submitObject.formAction = URL

Here, the URL can be an absolute url or a relative one.


Let us look at an example for the Submit formAction property −

<!DOCTYPE html>
<h1>Submit formAction Property</h1>
<form id="FORM_1" style="border:solid 2px green;padding:2px">
UserName: <input type="text" id="USR"> <br>
Location: <input type="text" id=“Loc”> <br><br>
<input type="submit" id="SUBMIT1" formaction="/New_page.php">
<p>Change the formAction attribute value to /Sample_page.php by clicking the below
<button onclick="formActChange()">CHANGE</button>
<p id="Sample"></p>
   function formActChange() {
      document.getElementById("Sample").innerHTML = "The formaction attribute value is
      now 'Sample_page.php'";


This will produce the following output −

On clicking the CHANGE button −