Issue when selecting all checkboxes
<p>i have this code which permits me to check all the checkboxes at once.</p>

<p>The problem is that when i select "select all" checkbox, it selects all the others, but if i have selected before 2 other checkboxes, it selects all except those two checkboxes!</p>

<p>It doesn't work properly..</p>

<p>can you please give it a look?</p>

<p>the function:</p>

<pre><code>function selectAll(x) {
for(var i=0,l=x.form.length; i&lt;l; i++)
if(x.form[i].type == 'checkbox' &amp;&amp; x.form[i].name != 'sAll')
x.form[i].checked=x.form[i].checked?false:true
}
</code></pre>

<p>the select all :</p>

<pre><code>&lt;input type="checkbox" name="sAll" onclick="selectAll(this)" /&gt; 
</code></pre>

<p>and all the other checkboxes in my page:</p>

<pre><code>&lt;input type='checkbox' size='40' name='active[$i] ' ' ";?&gt; &lt;?php if($rows['img_active'] == 1) { echo 'checked'; }  ?&gt; &lt;? if("checked"){ echo 'value="1"';} else{ echo 'value="0"';}?&gt;
</code></pre>
