Click to See Complete Forum and Search --> : Table rows and cells


Zero-x252
08-23-2003, 08:36 PM
Ok so I want this to work like so:
If say in another document a user has certain items checked and others not and it is saved in a cookie and the cookie is broken down i want to know how to remove the ones that arent checked and add extras when they werent there to begin etc... like so
var table_array= document.all.myTable.rows[0]
how would i number one write the loop and number two add the cells

Fang
08-24-2003, 05:56 AM
It is probably easier to display the complete table, including the extras.
Then loop through the table and hide the rows that are not required.

var ExcludeFromTable[]; // contains boolean list of rows to be removed
Tobj=document.getElementById('tableID');
// check that table has enough rows
if(Tobj.rows.length<=ExcludeFromTable.length) {
// first table row is 0;
for(var i=0; i< ExcludeFromTable.length; i++) {
if(ExcludeFromTable[i]) {
Tobj.rows[i].style.display="none";
}
}
}
else {
alert("Can't remove so many rows");
}
// note: if your table has a thead then Tobj=document.getElementById('tableID').tHead;