Page 2 of 3

Multiple Checkbox Values to localStorage

Posted: Thu Jan 23, 2014 10:31 am
by Kateryna Grynko

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


Multiple Checkbox Values to localStorage

Posted: Wed Sep 24, 2014 1:14 pm
by Amith Reddy

Image

how to read checked item label value


Multiple Checkbox Values to localStorage

Posted: Thu Sep 25, 2014 2:00 am
by Yurii Orishchuk

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.


Multiple Checkbox Values to localStorage

Posted: Fri Sep 26, 2014 6:33 am
by Amith Reddy

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


Multiple Checkbox Values to localStorage

Posted: Sun Sep 28, 2014 6:06 pm
by Alena Prykhodko

Please check browser console for errors.


Multiple Checkbox Values to localStorage

Posted: Mon Jul 13, 2015 3:39 am
by Nisa Khalid

how to map the data?


Multiple Checkbox Values to localStorage

Posted: Mon Jul 13, 2015 6:11 am
by Nisa Khalid

in the local storage what should i put?


Multiple Checkbox Values to localStorage

Posted: Thu Jul 16, 2015 1:03 pm
by Evgene Karachevtsev

Nisa,

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


Multiple Checkbox Values to localStorage

Posted: Fri Nov 06, 2015 9:53 pm
by Bruce Buttles

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 ...


Multiple Checkbox Values to localStorage

Posted: Wed Nov 11, 2015 8:13 am
by Serhii Kulibaba

Hello Bruce,

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