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.

Syntax

Following is the syntax for −

Setting the formAction property −

submitObject.formAction = URL

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

Example

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

<!DOCTYPE html>
<html>
<body>
<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">
</form>
<p>Change the formAction attribute value to /Sample_page.php by clicking the below
button</p>
<button onclick="formActChange()">CHANGE</button>
<p id="Sample"></p>
<script>
   function formActChange() {
      document.getElementById("SUBMIT1").formAction="/Sample_page.php";
      document.getElementById("Sample").innerHTML = "The formaction attribute value is
      now 'Sample_page.php'";
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking the CHANGE button −

Updated on: 18-Jun-2020

67 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements