Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-16-2002, 12:04 PM   PM User | #1
Guardian23
New Coder

 
Join Date: Jul 2002
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Guardian23 is an unknown quantity at this point
Tables and the DOM

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:

Code:
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
Guardian23 is offline   Reply With Quote
Old 09-16-2002, 02:22 PM   PM User | #2
Guardian23
New Coder

 
Join Date: Jul 2002
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Guardian23 is an unknown quantity at this point
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.

Guardian
Guardian23 is offline   Reply With Quote
Old 09-19-2002, 04:18 PM   PM User | #3
BrainJar
Regular Coder

 
Join Date: Jun 2002
Posts: 185
Thanks: 0
Thanked 0 Times in 0 Posts
BrainJar is an unknown quantity at this point
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/showthre...&threadid=6305
BrainJar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:34 PM.


Advertisement
Log in to turn off these ads.