Javascript examples for DOM HTML Element:Form
Form method Property - Return the method for sending form data:
<!DOCTYPE html> <html> <body> <form id="myForm" action="#" method="get" target="_blank"> First name: <input type="text" name="fname" value="Donald"><br> Last name: <input type="text" name="lname" value="Duck"><br> <input type="submit" value="Submit"> </form>/* ww w . jav a 2s . c o m*/ <button onclick="myFunction()">Change method</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myForm").method = "post"; document.getElementById("demo").innerHTML = "The method was set to 'post'."; } </script> </body> </html>