View Full Version : Tables and the DOM

09-16-2002, 01:04 PM
I've been having some problems with Tables and the DOM and

Anyway, I have a table tag in my page, and because of the general nature
of the table (it contains 64 squares (8X8, think chess)), and I've been trying to
do something like this:

for (i=0; i<8; i++) {
var tagA = document.createElement ("tr")//it's not this
for (ii=0; ii<8; ii++) {//it's not this
var tagB = document.creatElement ("td")
tagB.setAttribute ("@name", @value) //it's not this
//idname is the id of the table tag, and firstChild is it's only child
//with a tag name TBODY, it seems to get Appended by itself, and
//it always encases the contents of the table
//the @isn't actually in the code, I'm just using it as a abbreviation

It's not the code, because no matter how I change it, it always says:
"Exception Occurred" or "Unknown Runtime Error",
depending on whether I tried to set the attribute "innerHTML", or append a Node.

It seems to me, that the table is treated as a seperate entity all to itself.

So my question#1 is:
Is the TABLE element write protected? Because the only way I've ever been able
to modify one is by first removing it and using document.write to write a new one out :(


09-16-2002, 03:22 PM
Turns out that the createElement Method worked, but when I
tried using it the first time round, I forgot about the TBODY ?tag?.
Still, the innerHTML couldn't be set inside the TBODY tag, only
within it's children... so the innerHTML still seems a little quirky,
guess I'll just stick with the createElement method...

Sorry for the disturbance.


09-19-2002, 05:18 PM
If you're wanting to access table contents by row and column more directly, check the links I posted on the other thread - http://www.codingforums.com/showthread.php?s=&threadid=6305