Tuesday, May 11, 2004

To hide a column in a table

below is the code.

content=new Array()
function toggle(theChk) {
tb = document.getElementById("tb1");
id = theChk.value;
for (i=0;i<tb.rows.length;i++) {
for (j=0;j<tb.rows[i].cells.length;j++) {
if (tb.rows[i].cells[j].id.indexOf("col"+id)==0) {

if (chk) tb.rows[i].cells[j].innerHTML=content[tb.rows[i].cells[j].id]
else {
<input type="checkbox" onClick="toggle(this)" value="A" checked>
<input type="checkbox" onClick="toggle(this)" value="B" checked>
<input type="checkbox" onClick="toggle(this)" value="C" checked>
<table id="tb1">
<td id="colAcell0">ColA cell 0</td>
<td id="colBcell0">ColB cell 0</td>
<td id="colCcell0">ColC cell 0</td>
<td id="colAcell1">ColA cell 1</td>
<td id="colBcell1">ColB cell 1</td>
<td id="colCcell1">ColC cell 1</td>
<td id="colAcell2">ColA cell 2</td>
<td id="colBcell2">ColB cell 2</td>
<td id="colCcell2">ColC cell 2</td>

Web Hosting Cheap PHP Plans Also at For free flags of the world