Page 8 of 8

how to calculate label values in an array

Posted: Wed Dec 11, 2013 10:25 pm
by Michael4771079

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

how to calculate label values in an array

Posted: Thu Dec 12, 2013 10:04 am
by Kateryna Grynko

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.


how to calculate label values in an array

Posted: Thu Dec 12, 2013 1:26 pm
by Michael4771079

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


how to calculate label values in an array

Posted: Thu Dec 12, 2013 2:26 pm
by Kateryna Grynko

Hi Michael,

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


how to calculate label values in an array

Posted: Thu Dec 12, 2013 2:33 pm
by Michael4771079

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


how to calculate label values in an array

Posted: Thu Dec 12, 2013 3:18 pm
by Kateryna Grynko

Michael,

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


how to calculate label values in an array

Posted: Thu Dec 12, 2013 3:23 pm
by Michael4771079

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?


how to calculate label values in an array

Posted: Thu Dec 12, 2013 9:51 pm
by Maryna Brodina

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.


how to calculate label values in an array

Posted: Fri Dec 13, 2013 7:13 pm
by Michael4771079

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


how to calculate label values in an array

Posted: Fri Dec 13, 2013 7:49 pm
by Maryna Brodina

you're welcome:)