I'm trying to write a script where the unchecked values of a set of check-box are removed from a cookie. I am using jQuery's cookie plugin below is my current function which is called when a check-box is called;
<script type="text/javascript">
jQuery(document).ready(function($){
$("input[type=checkbox]").each(function () {
$(this).change(updateCount);
});
updateCount();
function updateCount () {
var val;
var my_cookie
var new_my_cookie;
$(':checkbox:checked').each(function(){
val= $(this).val();
my_cookie=$.cookie("chosen_ones");
$.cookie("chosen_ones", null);
new_my_cookie=my_cookie+"|"+val;
$.cookie("chosen_ones", new_my_cookie);
});
//somehow need to remove values from cookie when unchecked here
var length = $.cookie("chosen_ones").split("|").length;
length=length-1;
$("#count").text(length);
$("#status").toggle(length >= 0);
};
});
</script>
Any help would be welcomed.