[Javascript] visibility of a table column

John Deighan jdeighan at pcgus.com
Tue Oct 10 15:09:49 CDT 2006


I need to set the visibility of an entire column to hidden or 
visible. I was hoping that the following would work:

<table>
<colgroup>
	<col id="col1">
	...
</colgroup>
....
</table>

<button onclick="document.getElementById('col1').style.visibility = 'hidden';">
	Hide Column 1
</button>

However, when I try it, it doesn't work. Is it supposed to? I realize 
that I can set the visibility of all cells in that column, but it 
might be a very large table. I am using Firefox.

Actually, while composing this e-mail, I decided to try this under IE 
6. It sort of works. It hides the contents of the cells in that 
column. However, it doesn't make the column go away - in fact, the 
column retains its former width, so I assume it's computing that 
width from the data, which is still really there. To be honest, this 
seems like an odd solution, since it's the column's visibility that 
I'm setting, not the content of the column's cells. Does anyone know 
what the behaviour is supposed to be?




More information about the Javascript mailing list