I want to have a table and a textbox, when I input some value for the textbox then click the button, the value will be added into a table. I wrote the code but it doesn't run. Please help me to find out what wrong with the code below.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script>
function send() {
tbl=document.getElementById("idtable");
tr = document.createElement("tr");
td1 = document.createElement("td");
td2 = document.createElement("td");
name = document.getElementById("txtname").value;
email = document.getElementById("txtemail").value;
td1.innerText=name;
td2.innerText=email;
tr.appendChild(td1);
tr.appendChild(td2);
tbl.appendChild(tr);
}
</script>
</head>
<body>
<input type="text" id="txtname" name="txtname"/> <br/><br/>
<input type="text" id="txtemail" name="txtemail"/>
<p> <input type="button" value="Send" onclick="send()"/>
<table id="idtable" border="1">
<tr><td>Name</td>
<td>Email</td>
</tr>
</table>
</body>
</html>