Collapse Tables with specific Table ID? JavaScript

Posted by medoix on Stack Overflow See other posts from Stack Overflow or by medoix
Published on 2010-12-31T01:24:55Z Indexed on 2010/12/31 1:53 UTC
Read the original article Hit count: 517

Filed under:
|
|
|

I have the below JS at the top of my page and it successfully collapses ALL tables on load. However i am trying to figure out how to only collapse tables with the ID of "ctable" or is there some other way of specifying the tables to make collapsible etc?

<script type="text/javascript"> 

   var ELpntr=false;
   function hideall()
   {
      locl = document.getElementsByTagName('tbody');
      for (i=0;i<locl.length;i++)
      {
         locl[i].style.display='none';
      }
   }

   function showHide(EL,PM)
   {
      ELpntr=document.getElementById(EL);
      if (ELpntr.style.display=='none')
      {
         document.getElementById(PM).innerHTML=' - ';
         ELpntr.style.display='block';
      }
      else
      {
         document.getElementById(PM).innerHTML=' + ';
         ELpntr.style.display='none';
      }
   }
   onload=hideall;
</script>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html