The following code should give you an idea of how to do this. The example uses localStorage, but you might want to use cookies instead. There may be errors in it--I didn't run it.
First the HTML. Note the id and the event trigger.
<input type="checkbox" id = "c1" onchange="storeThis(this)">
Now the storeThis function:
function storeThis(ref){ //writes the value of checked status to localStorage
var val, id; //where the id of the checkbox is the key
id = ref.id;
val = ref.checked;
if(val){ //turn boolean value into a string--you can't store booleans in localStorage
val='true';
else{
val = 'false';
}
localStorage.setItem(id, val); //you might use a cookie for this instead
}
And finally something to be done upon reloading the page:
window.onload = function(){
var x, val;
val = localStorage.getItem('c1'); //see if an entry exists
if(val !== null){ //if the entry exists...
if(val == 'true'){ //convert string to boolean
val = true;
}
else{
val = false;
}
x = document.getElementById('c1'); //get the reference to the checkbox
x.checked = val; //set it to the recorded value
}
}