Page 2 of 3

Save checkbox values to local storage

Posted: Thu Jan 16, 2020 11:25 am
by Serhii Kulibaba

Is that grid generated by the service mapping, or you have created it manually?


Save checkbox values to local storage

Posted: Thu Jan 16, 2020 3:22 pm
by Ellen Schlechter

It is set by mapping.


Save checkbox values to local storage

Posted: Fri Jan 17, 2020 10:14 am
by Serhii Kulibaba

Please use the similar JS code to https://getsatisfaction.com/apperyio/...

You just need to make a loop through grids, not inputs


Save checkbox values to local storage

Posted: Mon Jan 20, 2020 10:12 pm
by Ellen Schlechter

Thank you for the advice. In doing that with the code below, I don't get each individual value.

prevar checkboxValues = [];
$("[name=mobilegrid_889 ]").each(function(){

var C = Apperyio("mobiletextinput_896").val();
var B = Apperyio("mobilelabel_895").text();
checkboxValues.push({C:C, B:B});
});

localStorage.setItem("arr", JSON.stringify(checkboxValues));/pre

It just returns 3 instead of two and each of them should be different instead of how they are all the same in this screenshot.. Image


Save checkbox values to local storage

Posted: Tue Jan 21, 2020 8:25 pm
by Serhii Kulibaba

Just change:

prevar C = Apperyio("mobiletextinput_896").val();
var B = Apperyio("mobilelabel_895").text();/pre
to:

prevar C = $(this).find("[name=mobiletextinput_896]").val();
var B = $(this).find("[name=mobilelabel_895]").text();/pre


Save checkbox values to local storage

Posted: Wed Jan 22, 2020 4:28 am
by Ellen Schlechter

Thank you! Do you know why it has an empty object last? It shouldn't be there at all... Image


Save checkbox values to local storage

Posted: Wed Jan 22, 2020 6:55 pm
by Serhii Kulibaba

Yes, this is a template object which is used in the mapping process.

Please ignore the last item here or check it before reading the values.

prevar checkboxValues = [];
$("[name=mobilegrid_889 ]").each(function(){
if (!$(this).parent().attr("data-appery-tpl")){
var C = Apperyio("mobiletextinput_896").val();
var B = Apperyio("mobilelabel_895").text();
checkboxValues.push({C:C, B:B});
}
});
localStorage.setItem("arr", JSON.stringify(checkboxValues));/pre


Save checkbox values to local storage

Posted: Sun Feb 02, 2020 3:32 pm
by Ellen Schlechter

So if I have it saved in local storage in the way you have outlined above, how do I get just the "B" values back through mapping? Right now, whatever I do only gives me the first value rather than all of the values stored.

This is how I have it mapped:
Image

And this is the code I am using with the mapping:
prevar arrayJS = value.C;
console.log("arrayJS = ", arrayJS);
var arrayJSON = JSON.stringify(arrayJS);
console.log("arrayJSON = ", arrayJSON);

return arrayJSON;/pre

The console shows my result. It only gets the first item rather than an "a, b, and c". Image

Any ideas on how to get everything??


Save checkbox values to local storage

Posted: Mon Feb 03, 2020 8:17 pm
by Serhii Kulibaba

Please don't use multiple input mapping arrows Image
It might break all your custom code.


Save checkbox values to local storage

Posted: Tue Feb 04, 2020 3:34 pm
by Ellen Schlechter

I have tried that but I still get about the same result. Image
Image