Input Submit formMethod Property - Change the method for sending form-data: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Submit

Description

Input Submit formMethod Property - Change the method for sending form-data:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form target="_blank">
  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" formaction="#" formmethod="get" value="Submit">
</form>//  w  ww. j a va2s .  c o  m

<button onclick="myFunction()">Change formmethod</button>

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

<script>
function myFunction() {
    document.getElementById("mySubmit").formMethod = "post";
    document.getElementById("demo").innerHTML = "The formaction is now 'POST'.";
}
</script>

</body>
</html>

Related Tutorials