Javascript examples for DOM HTML Element:Form
You can create a <form> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a FORM and an INPUT element</button> <script> function myFunction() {//from w w w .j av a 2s. co m var x = document.createElement("FORM"); x.setAttribute("id", "myForm"); document.body.appendChild(x); var y = document.createElement("INPUT"); y.setAttribute("type", "text"); y.setAttribute("value", "Donald"); document.getElementById("myForm").appendChild(y); } </script> </body> </html>