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

how to calculate label values in an array

Hi Michael,

'Star Pizza' seems to be another application. Are you sure it's 'Star Pizza'? We do not see any service handlers on 'checkout' page.

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

how to calculate label values in an array

Hi Katya,
yes it star pizza, this is the data tab on checkout page

Image

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

how to calculate label values in an array

Hi Michael,

[quote:]Price is not defined.[/quote]Where do you declare 'Price' variable? Please note 'price' and 'Price' are different names.

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

how to calculate label values in an array

Katya,
I have changed the code to price and the error has changed to this
I dont have price as a variable

Image

Image

Image

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

how to calculate label values in an array

Michael,

This is because you don't have a variable named "price".
There is also a typo. Please replaceprea.lenght/prewithprea.length/pre

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

how to calculate label values in an array

Hi Katya,
I have corrected the typo and add "price" and "extrasprice" as localstorage variables, I still get this error, how do I define these variables

Image

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

how to calculate label values in an array

When you add variables to localStorage, you should call them next:pre localStorage.getItem("name");/pre

where name - name of variable.

In your case better to add this lines before your code:
pre
var price = localStorage.getItem("price");
var extrasprice = localStorage.getItem("extrasprice ");/pre

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

how to calculate label values in an array

HI Alena,
I have added the code above, here is the new error "price is null"

Image

Image

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

how to calculate label values in an array

Hello! As you need arrays, not strings replace prevar price = localStorage.getItem("price");
var extrasprice = localStorage.getItem("extrasprice ");/pre with prevar price;
try {
price = JSON.parse(localStorage.getItem("price"));
if ({}.toString.call(price) !== "[object Array]") {
price = [];
}
} catch ( e ) {
price = [];
}

var extrasprice;
try {
extrasprice = JSON.parse(localStorage.getItem("extrasprice"));
if ({}.toString.call(extrasprice) !== "[object Array]") {
extrasprice = [];
}
} catch ( e ) {
extrasprice = [];
}/preAs we can see from your last error screenshot you don't have price localStorage variable. Please check localStorage variable name (note it's case sensitive). Check if it's saved correctly.

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

how to calculate label values in an array

Hi Marina,
I have added the code, I run the app but the code has no effect, errors are gone but nothing shows in localstorage
here are s/s of the code, the localstorage variables and the result of localstorage in firebug

Image

Image

Image

Return to “Issues”