Page 1 of 2

Javascript array not working

Posted: Mon Jul 07, 2014 1:07 pm
by Peter Abbruzzese

I have a app that uses a Javascript array to save checked items into local storage and display only those checked items onto the 2nd page.

Page 1:
var mobilecheckboxgroup = Apperyio("Checkbox_A").find(":checked");
var arr = [];
mobilecheckboxgroup.each(function(){
arr.push($(arr).val());
});
localStorage.setItem("arr", arr);

Image

Page 2:
var s = localStorage.getItem("arr");
Apperyio("Device2_label").text(s.replace(/,/gi,",\n"));

Image

Problem is nothing is being saved into localstorage and being sent to the 2nd page.
(2nd page is actually blank im using an old screen shot)


Javascript array not working

Posted: Mon Jul 07, 2014 2:53 pm
by Evgene Karachevtsev

Hello Peter,

There is an error in your code
Could you try to save the data this way:

codevar mobilecheckboxgroup = Apperyio("Checkbox_A").find (":"checked");
var arr = [];
mobilecheckboxgroup.each(function(i, elt){
arr.push($(elt).val());
});
localStorage.setItem("arr", arr);/code


Javascript array not working

Posted: Mon Jul 07, 2014 2:56 pm
by Peter Abbruzzese

Now im getting a bunch of Red X's saying the code isn't formatted correctly


Javascript array not working

Posted: Mon Jul 07, 2014 2:58 pm
by Peter Abbruzzese

Im still not getting anything on my 2nd page.


Javascript array not working

Posted: Mon Jul 07, 2014 4:09 pm
by Peter Abbruzzese

I got ride of the red X's

var mobilecheckboxgroup = Apperyio("Checkbox_A").find(":checked");
var arr = [];
mobilecheckboxgroup.each(function(i, Elt){
arr.push($(elt).val());
});
localStorage.setItem("arr", arr);

But Im still getting nothing on my 2nd page


Javascript array not working

Posted: Mon Jul 07, 2014 5:40 pm
by Peter Abbruzzese

???


Javascript array not working

Posted: Mon Jul 07, 2014 5:43 pm
by Evgene Karachevtsev

Peter,

We are working on it and will get back to you with update.


Javascript array not working

Posted: Mon Jul 07, 2014 8:40 pm
by Evgene Karachevtsev

Peter,

1) You have a typo

codefunction(i, Elt){
arr.push($(elt).val());
}/code
Elt and elt are the different variables

2) When you'll correct this error could you please check whether correct data saves in local storage or not


Javascript array not working

Posted: Wed Jul 09, 2014 1:14 pm
by Peter Abbruzzese

No nothing was saved

Image


Javascript array not working

Posted: Wed Jul 09, 2014 6:17 pm
by Evgene Karachevtsev

Peter,

Could you please give us public link to your application and steps how to reproduce the issue