Andrey Savitsky
Posts: 0
Joined: Sun May 19, 2013 3:53 pm

How can I get the value of the array on index?.

Hello.
I created an array. Image
How can I get the value of the array on index?.
Array is stored in a localstorage.

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

How can I get the value of the array on index?.

Hello,

At first you should convert a string to an array (values in localStorage are stored as a string):
var arr = jQuery.parseJSON(localStorage.getItem("arrayName"));

After this you'll get a simple array, its elements are available by index, for example:
alert(arr[0]);

Andrey Savitsky
Posts: 0
Joined: Sun May 19, 2013 3:53 pm

How can I get the value of the array on index?.

Where do I insert this code?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How can I get the value of the array on index?.

Hello!
You should add this code where you need to get value on index.

Andrey Savitsky
Posts: 0
Joined: Sun May 19, 2013 3:53 pm

How can I get the value of the array on index?.

Hello.
This code does not work.

Andrey Savitsky
Posts: 0
Joined: Sun May 19, 2013 3:53 pm

How can I get the value of the array on index?.

Help me, please.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How can I get the value of the array on index?.

Could you clarify where did you add this code? Screenshots would help.

Andrey Savitsky
Posts: 0
Joined: Sun May 19, 2013 3:53 pm

How can I get the value of the array on index?.

var arr = jQuery.parseJSON(localStorage.getItem("id"));
alert(arr[0]);
This code does not work.
Help me, please.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How can I get the value of the array on index?.

Please post screenshot where do you use this code?

Andrey Savitsky
Posts: 0
Joined: Sun May 19, 2013 3:53 pm

How can I get the value of the array on index?.

By clicking on the button.
Image

Return to “Issues”