Hiding divs with javascript collapse all
<p>I'm making divs with holds content and my problem is how to get all divs to collapse.
 Problem here is that the code needs to be dynamic since we don't know how many divs going to be made.</p>

<p>First here is my javascript:</p>

<pre><code>function pageLoad() 

var j = 1; while(j&gt;0)

collapseAll($('div'+j,'divx',+j));
j++;
</code></pre>

<p>This part handles collapse when page is loaded. All divs need to be collapsed.
in code it should be like this:</p>

<pre><code>&lt;a onclick="div('div1');" &gt; //this at first time
 &lt;div id="div1"&gt;
 content
&lt;/div&gt;    
&lt;a onclick="divx('divx1'); 
&lt;div id="divx1"&gt;
 content
&lt;/div&gt;
&lt;!-- this at next when div is created --&gt;
&lt;a onclick="div('div2');" &gt; 
&lt;div id="div2"&gt;
 content
&lt;/div&gt;
&lt;a onclick="divx('divx2'); "&gt;
&lt;div id="divx2"&gt;
 content
&lt;/div&gt;
</code></pre>

<p>and so on.. Problem here is that when code creates new div  it gives same name for div that is used in earlier part.</p>

<p>forexample:    </p>

<pre><code>&lt;a onclick="divx('divx2'); "&gt;
&lt;div id="divx2"&gt;
 content
 &lt;/div&gt;

//new div created:
&lt;a onclick="divx('divx2'); "&gt;
&lt;div id="divx2"&gt;
 content
 &lt;/div&gt;
</code></pre>
