:
<input type="button" onClick="addrow()">
:
: function addrow() {
: with (document)
: var table = (getElementById)? getElementById('table') : all['table'];
:
: table.addRow();
: }
:
: I haven't tested that, and I may have done some things I shouldn't, but it should give you the general idea.
:
I got this code to work but how do I add a check box not just text to the table?
td1.appendChild(document.createTextNode("want a check box here"))
Thanks!
function addRow(id){
var tbody = document.getElementById
(id).getElementsByTagName("TBODY")[0];
var row = document.createElement("TR")
var td1 = document.createElement("TD")
td1.appendChild(document.createTextNode("column 1")) //how do I get a check box or a text field?
var td2 = document.createElement("TD")
td2.appendChild (document.createTextNode("column 2"))
row.appendChild(td1);
row.appendChild(td2);
tbody.appendChild(row);
}
<a href="javascript:addRow('myTable')">Add row</a>
<table id="myTable" cellspacing="0" border="1">
<tbody>
<tr>
<td>row1_column1</td><td>row1_column1</td>
</tr>
</tbody>
</table>