Javascript examples for DOM HTML Element:Form
The Form object represents an HTML <form> element.
You can access a <form> element by using getElementById():
<!DOCTYPE html> <html> <body> <form id="myForm" action="/action_page.php"> 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>//w w w. j a v a 2 s .c om <button onclick="myFunction()">get the URL</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myForm").action; document.getElementById("demo").innerHTML = x; } </script> </body> </html>