<html>
<body>
<p>Click the button to create a FORM and an INPUT element.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
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>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_create by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:05:34 GMT -->
</html>