Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] hiding single td cells


  • From: list at tridemail.de (Michael Borchers)
  • Subject: [Javascript] hiding single td cells
  • Date: Tue Apr 25 07:44:10 2006

> First switch to using class. Then change the value to something
> allowed. Then run your document through the W3C Markup Validation
> Service. Then use getElementsByTag name to find all the table data
> cells. Then loop through them checking the className property. Alter
> the style.display property of those that match.

ok, i got it so far:
<table width="40%" cellpadding="0" cellspacing="2" border="1">
  <tr>
 <td>A</td>
 <td class="conversionsDetails" style="display:table-cell">B</td>
 <td class="conversionsDetails" style="display:table-cell">C</td>
...

the function:
{
 var conversionsDetails   = document.getElementsByTagName("td");
 var conversionsDetailsLength = conversionsDetails.length;
 
 for(tc=0;tc<conversionsDetailsLength;tc++)
 {
  if(conversionsDetails[tc].className == "conversionsDetails")
  {
   if(conversionsDetails[tc].style.display == '')
   {
    conversionsDetails[tc].style.display = "none";
   }
   else
   {
    if(conversionsDetails[tc].style.display == 'table-cell')
    {
     conversionsDetails[tc].style.display = "none";
    }
    else
    {
     conversionsDetails[tc].style.display = "table-cell";
    }
   }
  }
 }
}

it works fine when wanting them to disappear but
i can't bring'em back:( the display property seems to be missing, but why?