Page 1 of 2
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 2:22 pm
by Andrey Savitsky
Hello.
I created an array.
How can I get the value of the array on index?.
Array is stored in a localstorage.
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 2:39 pm
by Nikita
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]);
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 2:46 pm
by Andrey Savitsky
Where do I insert this code?
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 6:50 pm
by Maryna Brodina
Hello!
You should add this code where you need to get value on index.
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 6:54 pm
by Andrey Savitsky
Hello.
This code does not work.
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 6:55 pm
by Andrey Savitsky
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 7:03 pm
by Maryna Brodina
Could you clarify where did you add this code? Screenshots would help.
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 7:13 pm
by Andrey Savitsky
var arr = jQuery.parseJSON(localStorage.getItem("id"));
alert(arr[0]);
This code does not work.
Help me, please.
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 7:16 pm
by Maryna Brodina
Please post screenshot where do you use this code?
How can I get the value of the array on index?.
Posted: Thu Mar 20, 2014 7:24 pm
by Andrey Savitsky
By clicking on the button.