title: css javascript php div show/hide
body: <p>this is the code i have:</p>
  
  <pre><code>&lt;?
      while ($row1 = mysql_fetch_object($result1)) {
         echo '&lt;a href="#" onclick="showhide("'.$row1-&gt;id.'");"&gt;Name&lt;/a&gt;';
         while ($row2 = mysql_fetch_object($result2)) {
            echo '&lt;div id="'.$row1-&gt;id.'"&gt;';
            echo 'blabla';
            echo '&lt;/div&gt;';
         }
      }
  ?&gt;
      &lt;script&gt; 
      var state = 'none';
      function showhide(layer_ref){
      if(state == 'block'){
      state = 'none';
      }else{
      state = 'block';
      }
      if(document.all){ //IS IE 4 or 5 (or 6 beta)
      eval("document.all." +layer_ref+ ".style.display = state");
      }
      if (document.layers) { //IS NETSCAPE 4 or below
      document.layers[layer_ref].display = state;
      }
      if (document.getElementById &amp;&amp;!document.all) {
      hza = document.getElementById(layer_ref);
      hza.style.display = state;
      }
      }
      &lt;/script&gt;
  </code></pre>
  
  <p>this outputs something like:</p>
  
  <pre><code>Name
    blabla
  Name
    blabla
  ...
  </code></pre>
  
  <p>and when clicking on the head (name) it should toggle it contents (show/hide)
  but it doesn't. what am i doing wrong?</p>