[thelist] re: checkboxes, DOM, rows, etc

Fernando Gómez fgomez at criba.edu.ar
Thu Sep 19 17:31:01 CDT 2002


> But..won't this only get me one row each time I add? I need to add
> multiple rows..but replacing it..unless I misunderstand, will always
> give me one table with one row?

Tom:

I think this simplified code shows clearly the structure you need:

----------------------------------------------------
<form>
<table>
<tbody id="theTableBody">
<!-- initial row here -->
</tbody>
</table>
</form>

function addRow(someText) {
  var newRow = document.createElement("TR");
  var newCell = document.createElement("TD");
  var newText = document.createTextNode(someText);
  newCell.appendChild(newText);
  newRow.appendChild(newCell);
  document.getElementById("theTableBody").appendChild(newRow);
}
----------------------------------------------------

No need to replace children, no need no append tables; it just appends new
rows to the TBODY. And all of them live inside the form. Does it work? I
hope so! :)

Fernando Gómez




More information about the thelist mailing list