I have a form and a cookie that have to be of the same value of a checkbox input field, i want the cookie to change its value (true/false) when i check/uncheck the checkbox.
Here is what i tried but it doesn't seem to work :
<input id="checkbox1" type="checkbox" name="performance" value="checked" checked="checked"> checkbox number 1
if ($('input#checkbox1').is(':checked')) {
$.cookie('cookie1', 'true', { expires: 60});
} else {
$.removeCookie("cookie1");
$.cookie('cookie1', 'false', { expires: 60});
}
A jsFiddle: https://jsfiddle.net/kdfhb4n9/6/
I don't know what am I doing wrong, can you help?