<!DOCTYPE html>
<html>
<body>
<form action="demo_form.asp" method="get">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<button id="myBtn" type="submit" formmethod="post" formaction="demo_post.asp">Submit</button>
</form>
<p>Click the "Try it" button to return the value of the formmethod attribute of the submit button above.</p>
<p>Notice that the formmethod attribute overrides the HTML form's method attribute (get).</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myBtn").formMethod;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>