I have a checkbox whose value $row[\'uid\']
I would like to store in local storage using javascript or jquery. When the user \"unchecks\" the checkbox, the valu
localStorage
has two main functions, getItem
and setItem
. For setItem
you pass in a key and a value. If you write to that key again, it will rewrite that value. So in your case, if a box is checked you would do localStorage.setItem("checkbox_value", true)
and when it is unchecked you would pass in false
instead. To get the value you can look at using jQuery like so: $(checkbox).is(':checked')
and use a simple if-else clause to pass in true or false. then when you reload your page, on $( document ).ready()
you can get the values using localStorage.getItem(key)
and use Javascript to set the check boxes values.
This is how i would go about using localStorage to remember check box values.
Hope i helped! Ask me if anything is unclear.