I want to store a checkbox state in cookie with this :
<script type="text/javascript">
$(document).ready(function(){
var checkbox = $('#boxlawreg :checkbox'),
checkboxCookieName = 'checkbox-state';
checkbox.prop('checked', +$.cookie(checkboxCookieName));
checkbox.click(function() {
$.cookie(checkboxCookieName, +this.checked);
});
});
</script>
It’s work great but i have 7 checkbox and if i check one, reload my website, all the checkbox are check.
it’s look like :
<input type="checkbox" name="option1" value="1">
<input type="checkbox" name="option2" value="2">
<input type="checkbox" name="option3" value="3">
<input type="checkbox" name="option4" value="4">
Any ideas ?
(Ps: Sorry for the english, i’m french)
1 Answer