Input Submit formTarget Property - Change the value of the formtarget attribute of a submit button: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Submit

Description

Input Submit formTarget Property - Change the value of the formtarget attribute of a submit button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#" method="get">
  First name: <input type="text" name="fname" value="Mary"><br>
  Last name: <input type="text" name="lname" value="Bond"><br>
  <input type="submit" id="mySubmit" value="Submit" formtarget="_blank">
</form>//from  www  .ja  v  a  2  s  .  com

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

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

<script>
function myFunction() {
    document.getElementById("mySubmit").formTarget = "_self";
    document.getElementById("demo").innerHTML = "The value of the formtarget attribute was changed from '_blank' to '_self'.";
}
</script>

</body>
</html>

Related Tutorials