Click here to Skip to main content
15,886,547 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Please solve my problem

I have more than one radio button and checkbox in a project. They have individual ID . I want to save radiobutton or check box value in a local Storage in javascript. How can We solve this.. please give me some code.
Posted
Updated 25-Apr-16 22:58pm

 
Share this answer
 
 
Share this answer
 
Use JavaScript Cookies to store values in clients browser
 
Share this answer
 
Imagine a checkbox named cb1GRA2. To store the value in local Storage is so simple than
JavaScript
localStorage.setItem("cb1GRA2", $("#cb1GRA2").prop("checked"));


If you like to change every time the value changes you can use a JQuery function like

$("#cb1GRA2").change(function () { localStorage.setItem("cb1GRA2", $("#cb1GRA2").prop("checked")); });


To recover the data and restore de initial value to the control using JQuery:

JavaScript
$("#cb1GRA2").val(function () { $("#cb1GRA2").attr("checked", localStorage.getItem("cb1GRA2")); });
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900