Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

problem with array in localstorage

Hi Michael,

No, you can use the following code to save to variable:
prevar curent_order = $(this).find("option:selected").text();
localStorage.setItem("curent_item", curent_order);/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with array in localstorage

Hi,
trying to save the value of selectmenu to local storage. Katya suggested this code, but it doesn't work

var curent_order = $(this).find("option:selected").text();
localStorage.setItem("curent_item", curent_order);

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

problem with array in localstorage

Hello! It works as we can see, but you have a typo in JS on chickenpizzaselectmenu-Value change. You have:
pre$(this).closest("[name=chickenpizzamobilegrid]").find("[dsid=chickenpizzaPricelabel]").text(localStorage.getItem("current_order"));/pre but should be pre$(this).closest("[name=chickenpizzamobilegrid]").find("[dsid=chickenpizzaPricelabel]").text(localStorage.getItem("curent_order"));/pre
you set curent_order variable but retrieve current_order (double rr)

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with array in localstorage

Thanks Marina,
but the code below doesn't save the selectmenu value in localstorage

var curent_order = $(this).find("option:selected").text();
localStorage.setItem("curent_item", curent_order);

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

problem with array in localstorage

Try
prevar curent_order = $(this).find("option:selected").val();
localStorage.setItem("curent_item", curent_order);/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with array in localstorage

Hi,
This is the result, it is saving the value in localstorage

this is the code I have to get the value, it returns null

code$(this).closest("[name=chickenpizzamobilegrid]").find("[dsid=chickenpizzaPricelabel]")
.text(localStorage.getItem("curent_order"));/code

Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

problem with array in localstorage

Hi Michael,

Please delete all your JavaScript codes on chickenpizzaselectmenu-Value change
and create an only JS code instead:
prevar curent_item = $(this).find("option:selected").text();
localStorage.setItem("curent_item", curent_item);
$(this).closest("[name=chickenpizzamobilegrid]").find("[dsid=orderlabel]").text(localStorage.getItem("curent_item"));
var curent_order = $(this).find("option:selected").val();
localStorage.setItem("curent_order", curent_order);
$(this).closest("[name=chickenpizzamobilegrid]").find("[dsid=chickenpizzaPricelabel]").text(localStorage.getItem("curent_order"));/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with array in localstorage

Thanks Katya, all working now,
I didn't think it would make a difference using 1 event or 4 as long as they were in the correct order.

thanks alot

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

problem with array in localstorage

Michael,

This wouldn't make a difference, there were some typos in your code.
It's all together, you can see where the names are used and where are not.

Return to “Issues”