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

Tom Dell'Aringa pixelmech at yahoo.com
Thu Sep 19 17:50:00 CDT 2002

--- Fernando_Gómez <fgomez at criba.edu.ar> wrote:
> 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! :)

I feel like we're so close I can TASTE it..arrrgh..

I adjusted yours slightly to work with my page thus:
function addDoctor(name, city, id)
  var docTarget = window.frames['docs'].document;
  var myTable = docTarget.getElementById('mydocs');
  var myTableBody = docTarget.createElement("TBODY");
  var newRow = docTarget.createElement("TR");
  var newCell = docTarget.createElement("TD");
  var newText = docTarget.createTextNode('someText');
Remember, I am using a page with iframes and this is called from one
of the iframes. I tried changing window.frames to parent.frames with
no effect.

This essentially gives me an error on the last line - getElementById
is NULL or not an object.

I don't fully understand the table body thing anyway - maybe this is
the problem. Should I just PUT a <tbody> tag in my table first? Do I
need that..why doesn't it see the table body?


var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

More information about the thelist mailing list