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.
--JS--
$('.CheckBox').toggle(function(){
$('#Counter').html('( '+i+' Selected )');
i++;
}, function() {
$('#Counter').html('( '+i+' Selected )');
i--;
});
---PHP---
do { ?>
<div style="position:relative; width:100%; height:20px; background-color:#FF5300;" class="CheckBox" id="<?php echo $row_EX['x1']; ?>">
<input type="checkbox" name="<?php echo $row_EX['x2']; ?>" value="<?php echo $row_EX['x3']; ?>" style="cursor:pointer; ">
<span style="position:relative; top:-2px; font-family:arial; color:#000; font-size:12px;"><?php echo $row_EX['lx4']; ?></span>
</div>
<div style="height:1px; width:1px;"></div>
<?php } while ($row_EX = mysql_fetch_assoc($EY)); ?>
<span style="position:relative; left:10px; top:6px; font-family:arial; font-size:16px;" id="counter">(0 Selected)</span>