Button formAction Property - Change the value of the formaction attribute of a button: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Button

Description

Button formAction Property - Change the value of the formaction attribute of a button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form method="get">
First name: <input type="text" name="fname" value="Mary"><br>
Last name: <input type="text" name="lname" value="Bond"><br>
<button id="myBtn" type="submit" formaction="#">Submit form</button>
</form>//w  w  w.  java2 s.c  o  m

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
    document.getElementById("myBtn").formAction = "/action_page2.php";
    document.getElementById("demo").innerHTML = "The value of the formaction attribute was changed to 'action_page2.php'.";
}
</script>

</body>
</html>

Related Tutorials