javascript - check the checkbox on load but if the page reloads must remember last state -


I have a group of checkboxes that should be checked when page loads. I have an onload script to check the automatic checkbox, but when I unchecked the checkbox and reloaded the page, it is still checked. How can it remember this in the end? Thanks in advance

try it ...

  var i , Checkbox = document.querySelectorAll ('input [type = checkbox]'); Function save () {for (i = 0; i & lt; checkbox length; i ++) {localStorage.setItem (checkbox [i] .value, checkbox [i] check); }} Function load_ () {for (i = 0; i & lt; checkbox length; i ++) {checkbox [i]. Checked = localStorage.getItem (checkbox [i] .value) === 'true'? right wrong; }}   

Wisdom of working: -

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -