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

how to calculate label values in an array

Hi Maryna,
thx for reply,

  1. I have removed the bracket
  2. still dont know the details on the code Katya suggested above
  3. this code "Math.round(totalprice).toFixed(2)"
    was suggested to round off the totalprice and display with 2 decimal points.
    I can delete this, but how do I round the number and display with 2 decimals
Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

how to calculate label values in an array

Hi Michael,

Now we don't see this code:preMath.round(totalprice).toFixed(2)/preDid you delete it?
Marina meant 'totalprice' variable was not defined at the moment. If you need it, define it and use.

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

how to calculate label values in an array

OK Katya,
I had deleted the code,
the code has been re added.
to define "totalprice" what do I add?

as regards the code you suggested yesterday

if($this.attr("idx").slice(1))){
...
var index = parseInt($this.attr("idx").slice(1));
....
}

is the what you mean

codevar mainorderArray;
try {
mainorderArray = JSON.parse(localStorage.getItem("mainorderArray"));
if ({}.toString.call(mainorderArray) !== "[object Array]") {
mainorderArray = [];

}
} catch ( e ) {
mainorderArray = [];
}
var $this = $(this);
if($this.attr("idx").slice(1)))
var index = parseInt($this.attr("idx").slice(1));
if (index >=0 && index < mainorderArray&#46;length) {
mainorderArray&#46;splice(index, 1);
}
localStorage&#46;setItem("mainorderArray", JSON&#46;stringify(mainorderArray));
/code

thx

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

how to calculate label values in an array

Hi Michael,

You can also move this code to a condition:prelocalStorage&#46;setItem("mainorderArray", JSON&#46;stringify(mainorderArray));/pre

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

how to calculate label values in an array

I'm sorry Katya,
I dont know what a condition is or how to implement it,

is the code from yesterday correct?

to define "totalprice" what do I add?

codevar mainorderArray;
try {
mainorderArray = JSON&#46;parse(localStorage&#46;getItem("mainorderArray"));
if ({}&#46;toString&#46;call(mainorderArray) !== "[object Array]") {
mainorderArray = [];

}
} catch ( e ) {
mainorderArray = [];
}
var $this = $(this);
if($this&#46;attr("idx")&#46;slice(1)))
var index = parseInt($this&#46;attr("idx")&#46;slice(1));
if (index >=0 && index < mainorderArray&#46;length) {
mainorderArray&#46;splice(index, 1);
}
localStorage&#46;setItem("mainorderArray", JSON&#46;stringify(mainorderArray));
/code

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

how to calculate label values in an array

Michael,

It depends on what you want to store in this variable.

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

how to calculate label values in an array

I dont know what question you have answered

I'm sorry Katya,
I dont know what a condition is or how to implement it,

is the code from yesterday correct?

to define "totalprice" what do I add?

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

how to calculate label values in an array

1) On screen checkout on Delete button click in first action should be the following code: prevar mainorderArray;
try {
mainorderArray = JSON&#46;parse(localStorage&#46;getItem("mainorderArray"));
if ({}&#46;toString&#46;call(mainorderArray) !== "[object Array]") {
mainorderArray = [];
}
} catch ( e ) {
mainorderArray = [];
}
var $this = $(this);
if($this&#46;attr("idx")&#46;slice(1)) {
var index = parseInt($this&#46;attr("idx")&#46;slice(1));
if (index =0 && index < mainorderArray&#46;length) {
mainorderArray&#46;splice(index, 1);
}
}

localStorage&#46;setItem("mainorderArray", JSON&#46;stringify(mainorderArray));/pre2) On checkout screen STARRUSERREAD-Complete delete both actions. Instead add JS with the following code prevar totalprice = parseFloat(localStorage&#46;getItem("totalprice"))&#46;toFixed(2);
Appery("mobilelabel_112")&#46;text(totalprice);/pre3) On Login screen from Login button delete mobilebutton_3-Click-2. Run JavaScript action. You don't need this code here. It's a code handler of removing order item.

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

how to calculate label values in an array

Hi Maryna,
I just wanted to say thank you very much for your great input on this, its much appreciated

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

how to calculate label values in an array

you're welcome:)

Return to “Issues”