Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Multiple Checkbox Values to localStorage

Hi Doug,

Function Appery doesn't accept the second parameter. An only parameter is a component name.

To set a flag use code .prop('checked', 'checked')/code, then you would need to refresh component view. You use code.checkboxradio("refresh")/code. We'd advise you more correct standardized mechanism for Appery.io components - method code.refresh()/code.
prevar arr = new Array();
arr = Appery("guardianCheckBox").find(":checked").map(function(el) {
return el.val();
});

if (arr.length == 0) {
alert("Please select a guardian!");
return;
}

if (arr.length 2) {
alert("Please select only 2 guardians!");
} else {
var items = ['selectedGuardian', 'selectedGuardian2'];

Code: Select all

 $.each(arr, function(i, value){ 
     localStorage.setItem(items[i], value); 
 }); 

 addChild.execute(); 

}
// restore from localStorage

var items = ['selectedGuardian', 'selectedGuardian2'];
$.each(arr, function(i, key){
var value = localStorage.getItem(key);
Appery("guardianCheckBoxList")
.find("input[value='" + value + "']:first")
.prop('checked', 'checked')
.refresh();
});/pre

Amith Reddy
Posts: 0
Joined: Wed Aug 06, 2014 5:48 am

Multiple Checkbox Values to localStorage

Image

how to read checked item label value

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Multiple Checkbox Values to localStorage

Hi Amith,

You can use following code for this goal(please read comments to understand how to modify it for your case):

pre

//Note: Replace "mobilecheckbox_146" with your checkbox name.
var checkedCheckboxes = jQuery('[name="mobilecheckbox_146"] input:checked').closest('[name="mobilecheckbox_146"]');

for(var i = 0; checkedCheckboxes.length; i++){
//Replace "mobilelabel_149" with your goal text label name.
var currentItemText = jQuery(checkedCheckboxes).find('[name="mobilelabel_149"]');.text().trim();

Code: Select all

 //Here is using currunt checked item text. You can change it in accordance to your needs. 
 alert(currentItemText); 

};

/pre

Regards.

Amith Reddy
Posts: 0
Joined: Wed Aug 06, 2014 5:48 am

Multiple Checkbox Values to localStorage

Hi Yurii Orishchuk
the code is not working and one more thing its not showing any error also while running

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Multiple Checkbox Values to localStorage

Please check browser console for errors.

Nisa Khalid
Posts: 0
Joined: Tue May 05, 2015 1:36 pm

Multiple Checkbox Values to localStorage

how to map the data?

Nisa Khalid
Posts: 0
Joined: Tue May 05, 2015 1:36 pm

Multiple Checkbox Values to localStorage

in the local storage what should i put?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Multiple Checkbox Values to localStorage

Nisa,

I'm sorry, but unfortunately your question isn't clear, could you please clarify it with more details?

Bruce Buttles
Posts: 0
Joined: Tue Oct 20, 2015 7:44 pm

Multiple Checkbox Values to localStorage

Kateryna, what if the localStorage variable is actually an ARRAY? I created a MODEL that is an array and defined the localStorage as they array type.
QUESTION: what is the code to actually store values into the localStorage array?

This is what I am trying:
localStorage.setItem(my_local_Array, arr);

arr is the JavaScript array and my_local_Array is the local storage array ...

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Multiple Checkbox Values to localStorage

Hello Bruce,

Please look at this documentation: https://devcenter.appery.io/documenta...

Return to “Issues”