Skip to content

Instantly share code, notes, and snippets.

@GiacomoLaw
Created March 14, 2017 14:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GiacomoLaw/79b604401cdfd3e6910d68a4c5ebe895 to your computer and use it in GitHub Desktop.
Save GiacomoLaw/79b604401cdfd3e6910d68a4c5ebe895 to your computer and use it in GitHub Desktop.
Saves the status of checkboxes to your local disk
var i, checkboxes = document.querySelectorAll('input[type=checkbox]');
function save() {
for (i = 0; i < checkboxes.length; i++) {
localStorage.setItem(checkboxes[i].value, checkboxes[i].checked);
}
}
function load_() {
for (i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = localStorage.getItem(checkboxes[i].value) === 'true' ? true:false;
}
}
// View the Codepen here: http://codepen.io/GiacomoLaw/pen/evEZMQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment