ReportingAnalyst
MIS
Hi,
Could help in giving me ideas as to how I can make this work? I would like to show and hide a table column by clicking on a a href link.
Could help in giving me ideas as to how I can make this work? I would like to show and hide a table column by clicking on a a href link.
Code:
<html>
<head>
<title>Show and Hide Table Column</title>
<script type="text/javascript">
function show_hide(obj){
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
for(var i = 0; i < lastRow; i++) {
obj = document.getElementById('invisible').style;
(obj.display == 'none')? obj.display = 'block' : obj.display = 'none';
}
}
</script>
</head>
<body>
<a href="#" onClick="show_hide(this);">Show and Hide</a>
<table border="1" cellspacing="1" width="100%" height="96" id="tblSample">
<tr>
<td width="25%" height="19">Column1</td>
<td width="25%" height="19">Column2</td>
<td width="25%" height="19">Column3</td>
<td id="invisible" width="25%" height="19">Column4</td>
</tr>
<tr>
<td width="25%" height="19">a</td>
<td width="25%" height="19">b</td>
<td width="25%" height="19">c</td>
<td id="invisible" width="25%" height="19">123</td>
</tr>
<tr>
<td width="25%" height="19">d</td>
<td width="25%" height="19">e</td>
<td width="25%" height="19">f</td>
<td id="invisible" width="25%" height="19">456</td>
</tr>
<tr>
<td width="25%" height="19">g</td>
<td width="25%" height="19">h</td>
<td width="25%" height="19">i</td>
<td id="invisible" width="25%" height="19">789</td>
</tr>
</table>
</body>
</html>