I have created form. now I need to take input data into table. So I have created the code but it does not working. In here, I take the input-data by using id = "input1" then I click on the submit button and it will call for myfunction() function. That function will show the data in the table. But it not working.
<html>
<head>
<title>
</title>
</head>
<body>
<div id="form1">
</div>
<div id="table1">
</div>
<script>
var f = document.createElement("form");
var i = document.createElement("input");
i.setAttribute('type',"text");
i.setAttribute('name',"input1");
i.setAttribute('id',"input1");
var s = document.createElement("input");
s.setAttribute('type',"submit");
s.setAttribute('value',"Submit");
s.setAttribute('id',"done")
f.appendChild(i);
f.appendChild(s);
document.getElementById("form1").appendChild(f);
</script>
<script>
document.getElementById("done").onclick = function() {myFunction()};
function myFunction() {
var t = document.createElement("table");
t.setAttribute('border',"1");
var row = document.createElement("tr");
var cell = document.createElement("td");
var cellText = document.getElementById("input1");
cell.appendChild(cellText);
row.appendChild(cell);
t.appendChild(row);
document.getElementById("table1").appendChild(t);
}
</script>
</body>
</html>