Guardian23
09-16-2002, 12:04 PM
I've been having some problems with Tables and the DOM and
JavaScript.
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
document.getElementById("idname").firstChild.appendChild(tagA)
for (ii=0; ii<8; ii++) {//it's not this
var tagB = document.creatElement ("td")
tagB.setAttribute ("@name", @value) //it's not this
document.getElementById("idname").firstChild.childNodes[i].appendChild(tagB)
}
}
//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 :(
Guardian
JavaScript.
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
document.getElementById("idname").firstChild.appendChild(tagA)
for (ii=0; ii<8; ii++) {//it's not this
var tagB = document.creatElement ("td")
tagB.setAttribute ("@name", @value) //it's not this
document.getElementById("idname").firstChild.childNodes[i].appendChild(tagB)
}
}
//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 :(
Guardian