Peter Abbruzzese
Posts: 0
Joined: Tue Jul 01, 2014 3:27 pm

Javascript array not working

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)

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

Javascript array not working

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

Peter Abbruzzese
Posts: 0
Joined: Tue Jul 01, 2014 3:27 pm

Javascript array not working

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

Peter Abbruzzese
Posts: 0
Joined: Tue Jul 01, 2014 3:27 pm

Javascript array not working

Im still not getting anything on my 2nd page.

Peter Abbruzzese
Posts: 0
Joined: Tue Jul 01, 2014 3:27 pm

Javascript array not working

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

Peter Abbruzzese
Posts: 0
Joined: Tue Jul 01, 2014 3:27 pm

Javascript array not working

???

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

Javascript array not working

Peter,

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

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

Javascript array not working

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

Peter Abbruzzese
Posts: 0
Joined: Tue Jul 01, 2014 3:27 pm

Javascript array not working

No nothing was saved

Image

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

Javascript array not working

Peter,

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

Return to “Issues”