Save checkbox values to local storage

This forum contains topics that were moved from Get Satisfaction
Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Save checkbox values to local storage

Post by Serhii Kulibaba »

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

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

Save checkbox values to local storage

Post by Ellen Schlechter »

It is set by mapping.

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

Save checkbox values to local storage

Post 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

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

Save checkbox values to local storage

Post 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

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

Save checkbox values to local storage

Post 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

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

Save checkbox values to local storage

Post by Ellen Schlechter »

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

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

Save checkbox values to local storage

Post 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

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

Save checkbox values to local storage

Post 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??

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

Save checkbox values to local storage

Post by Serhii Kulibaba »

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

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

Save checkbox values to local storage

Post by Ellen Schlechter »

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

Post Reply