Hide a table column in IE

I

Ian Collins

I'm having a spot of bother hiding table columns in IE.

With FF, setting the column cell's style.display to none (or changing
the cell's class name to style that has display: none) completely
removes the cells from the table.

In IE, the cell contents go, but the space they occupied is still there,
so the table has an empty column, the same result as setting visibility
= invisible.

Known bug or me doing something stupid?
 
E

Evertjan.

Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:
I'm having a spot of bother hiding table columns in IE.

With FF, setting the column cell's style.display to none (or changing
the cell's class name to style that has display: none) completely
removes the cells from the table.

In IE, the cell contents go, but the space they occupied is still there,
so the table has an empty column, the same result as setting visibility
= invisible.
Known bug or
me doing something stupid?

Possibly, please show relevant code.
 
I

Ian Collins

Evertjan. said:
Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:




Possibly, please show relevant code.

var rows = table.rows;

for( var n = rows.length-1; n > 0; --n )
{
if( rows[n].info.key == key )
{
rows[0].cells[4].style.display = 'none';
rows[n].cells[4].style.display = 'none';
}
}
 
I

Ian Collins

Ian said:
Evertjan. said:
Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:





Possibly, please show relevant code.


var rows = table.rows;

for( var n = rows.length-1; n > 0; --n )
{
if( rows[n].info.key == key )
{
rows[0].cells[4].style.display = 'none';
rows[n].cells[4].style.display = 'none';
}
}
Cutting the code for posting made me realise what I'd done wrong.

All of the other table rows hand been hidden and I was hiding a column
in the remaining visible rows only.

This works OK in FF, but to make this work in IE, you have to hide the
column in all the rows of the table, not just the visible ones.
 
E

Evertjan.

Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:
var rows = table.rows;

table is not an object, I suspect.
for( var n = rows.length-1; n > 0; --n )
n--

{
if( rows[n].info.key == key )

what is info, what is key, what is key (2)
{
rows[0].cells[4].style.display = 'none';

why do this n-1+1 times?
rows[n].cells[4].style.display = 'none';
}
}

Better define your table using:

var tbl = document.getElementById('myTableID')
for( var n = tbl.rows.length-1; n >= 0; n-- )
// if(tbl.rows[n].innerHTML != 'blah')
tbl.rows[n].cells[4].style.display = 'none';

not tested
 
E

Evertjan.

Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:

My mistake, they act the same:

for( var n = 7-1; n > 0; --n )
document.write(n+"<br>");

for( var n = 7-1; n > 0; n-- )
document.write(n+"<br>");

both miss the 0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top