467,119 Members | 1,015 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,119 developers. It's quick & easy.

Hide a table column in IE

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?

--
Ian Collins.
May 8 '06 #1
  • viewed: 4845
Share:
6 Replies
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 8 '06 #2
Evertjan. wrote:
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.


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';
}
}

--
Ian Collins.
May 8 '06 #3
Ian Collins wrote:
Evertjan. wrote:
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.

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.

--
Ian Collins.
May 8 '06 #4
Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:
Evertjan. wrote:
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.


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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 8 '06 #5
Evertjan. wrote:
Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:

Evertjan. wrote:
for( var n = rows.length-1; n > 0; --n )

n--

Why?

--
Ian Collins.
May 8 '06 #6
Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:
Evertjan. wrote:
Ian Collins wrote on 08 mei 2006 in comp.lang.javascript:

Evertjan. wrote:

for( var n = rows.length-1; n > 0; --n )

n--

Why?


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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 8 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Don Grover | last post: by
6 posts views Thread by Das | last post: by
4 posts views Thread by Tim | last post: by
2 posts views Thread by jeet_sen | last post: by
3 posts views Thread by =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.