Click to See Complete Forum and Search --> : Accessing Objects from Arrays


eok20
08-11-2003, 11:55 AM
I have a function that changes the color of a bunch tables by individualling doing "tableID.style.backgroundcolor=" for each table. Is there any way that i can create an array of the table IDs so i can change the tables' properties in a loop? Thanks in advanced for any help.

Fang
08-11-2003, 02:17 PM
function TableLoop() {
var TableList=document.getElementsByTagName('table')
for(var idx=0; idx<TableList.length; idx++) {
TableList[idx].style.background="red";
}
}

eok20
08-11-2003, 03:54 PM
thanks but I should have been more clear. i only need to change the bg colors of a few of the tables, not all of them so they will not work.

Fang
08-12-2003, 04:03 AM
"TableList" is an array of all your tables, just change the ones that need changing.