PDA

View Full Version : creating a table with createElement, is it possible?!



ConfusedOfLife
Mar 29th, 2003, 12:23 PM
Hi, I was killing myself to make a table with createElement, but finally I couldn't do it! Here it is my code, do you know anyway that I can make it?!



<script>
tab = document.createElement("table");
tab.setAttribute("border", "5");
document.body.appendChild(tab);

tr = document.createElement("tr");
tab.appendChild(tr);

td = document.createElement("td");
td.innerHTML = "Why don't you work?!";
tr.appendChild(td);

</script>


Thank you in advance ( I terribly need it! )
bijan

Vladdy
Mar 29th, 2003, 01:34 PM
tr can be appended only to thead or tbody

See my dynamic table code at http://www.vladdy.net/webdesign/DOM_Tables.html