<!DOCTYPE html>
<html>
<body>

<form target="_blank">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<button id="myBtn" formaction="demo_form_method.asp" formmethod="get"  type="submit">Submit</button>
</form>

<p>Click the "Try it" button to change the value of the formmethod and formaction attributes of the submit button in the form above.</p>

<p><b>Note:</b> Click on the "Submit" button before and after you have clicked on the "Try it" button, to see the effect!</p>

<button onclick="myFunction()">Try it</button>

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

<script>
function myFunction() {
    document.getElementById("myBtn").formMethod = "post";
    document.getElementById("myBtn").formAction = "demo_form_method_post.asp";
    document.getElementById("demo").innerHTML = "The value of formaction and formmethod was changed.";
}
</script>

</body>
</html>