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

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -

sql server ce - Is there some way to make sqlce3.5 and 4.0 co-exist in the C# project -