...

View Full Version : childObjects of a table/tbody



bradgrafelman
12-17-2004, 12:09 AM
Ok. I have to learn this sometime I guess, lol.

I want to cycle through each row of a table and perform a function on it. In the past, I've simply given each row an ID number, like (id="row1", id="row2") etc. I now have a huge table, and that would be tiresome.

I need to find a way to use some method of cycling through each table's rows and performing a function on it. I thought something like "theTable.childObjects" would do the trick, but I'm not sure what I'm doing. If at all possible, can all of the child objects of a <TBODY> tag be cycled through instead of an entire table? If not, that's ok. I just need *some* method of doing this other than the row numeration.

HELP!

Thanks in advance.

glenngv
12-17-2004, 01:14 AM
<table>
<tbody id="blah">
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</tbody>
</table>
...
var rows = document.getElementById('blah').getElementsByTagName("TR");
for (var i=0; i<rows.length; i++)
{
alert(rows[i]);
}

bradgrafelman
12-17-2004, 01:53 AM
ok.... hmm... that worked great except...


how do i get the CSS class name of an object? i.e.:

<TR class=scheduleES>...

in the above script, i tried rows[i].class but it didnt work. any help?

glenngv
12-17-2004, 02:00 AM
rows[i].className

bradgrafelman
12-17-2004, 02:08 AM
very sorry. i didn't search the MSDN 'object' database before posting :(

thanks for all your help!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum