Count + / - for checkbox click and unclick
<p>When a user clicks the checkbox the counter #counter +1, thats fine,  but when he unchecks it does not -1 for the same checkbox. I want to +1 when they click a particular checkbox and when unchecking -1.</p>

<p>--JS--</p>

<pre><code>$('.CheckBox').toggle(function(){
    $('#Counter').html('( '+i+' Selected )');
    i++;
}, function() {

    $('#Counter').html('( '+i+' Selected )');
    i--;
});
</code></pre>

<p>---PHP---   </p>

<pre><code>do { ?&gt;

&lt;div style="position:relative; width:100%; height:20px; background-color:#FF5300;" class="CheckBox" id="&lt;?php echo $row_EX['x1']; ?&gt;"&gt;

&lt;input type="checkbox" name="&lt;?php echo $row_EX['x2']; ?&gt;" value="&lt;?php echo $row_EX['x3']; ?&gt;" style="cursor:pointer; "&gt;

&lt;span style="position:relative; top:-2px; font-family:arial; color:#000; font-size:12px;"&gt;&lt;?php echo $row_EX['lx4']; ?&gt;&lt;/span&gt;

&lt;/div&gt;

&lt;div style="height:1px; width:1px;"&gt;&lt;/div&gt;
&lt;?php } while ($row_EX = mysql_fetch_assoc($EY)); ?&gt;    

&lt;span style="position:relative; left:10px; top:6px; font-family:arial; font-size:16px;" id="counter"&gt;(0 Selected)&lt;/span&gt;
</code></pre>
