<html> <head> <script type="text/javascript"> function changeAction() { var x=document.getElementById("myForm"); alert("Original action: " + x.action); x.action="default.asp.htm"; alert("New action: " + x.action); x.submit(); } </script> </head> <body> <form id="myForm" action="https://w3schools.sinsixx.com/js/js_examples.asp"> Name: <input type="text" value="Mickey Mouse" /> <input type="button" onclick="changeAction()" value="Change action attribute and submit form" /> </form> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself