Javascript DOM HTML Input Submit formAction Property get

Introduction

Get the file URL that will process the input control:

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

Click the button to display the value of the formaction attribute of the submit button.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
  First name: <input type="text" name="fname" value="CSS"><br>
  Last name: <input type="text" name="lname" value="HTML"><br>
  <input type="submit" id="mySubmit" formaction="/action_page2.php" value="Submit">
</form>//from   w ww  .j a  v a  2  s  .  com
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("mySubmit").formAction;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The formAction property sets or gets the formaction attribute of a submit button.

The formaction attribute sets the URL that will process the input control.

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

The formAction property returns a String representing the URL for where to send the form-data.




PreviousNext

Related