Tuesday, October 27, 2009

Collapsible javascript

I believe this should work with all browsers when added to the onClick handler of what you want to trigger it. Set the div, span, etc. to have an initial display of one of the two for a fresh page load. Also I selected inline, your application may prefer block for some parts.

<script type="text/javascript">

    function ShowHide(id) {

    
var elementStyle=document.getElementById(id).style

    elementStyle.display = elementStyle.display ==
"inline" ? "none" : "inline";

}


Example:


<h2>

<span onclick="ShowHide('SessionVarHider');">Session</span><span style="display:none" id="SessionVarHider"> -

</h2>


  <ul id="sessionVars">

      <!--<li><a href="#">Aliquam libero</a></li>-->

      <%= SessionVariableList() %>

  
</ul>

  </span>

No comments:

Post a Comment