Page 1 of 1

Calculate 2 boxes

Posted: Mon Mar 16, 2015 12:34 am
by Mark7294305

Hello Support
I have an App where I wish to add the totals of two input boxes together. For example in Box A I receive prices from an Api which go into this box. Box B contains the current balance. I wish for Box C to equal Box A + Box B,

How do I do this?


Calculate 2 boxes

Posted: Mon Mar 16, 2015 1:02 am
by She

Hi mark,

for example you have 2 textInput and name it A,B,

var a = parseInt(Appery("a").val());
var b = parseInt(Appery("b").val());
alert(a+b);


Calculate 2 boxes

Posted: Mon Mar 16, 2015 7:20 am
by Mark7294305

Hi
How do I make the results of A + C appear in box C?


Calculate 2 boxes

Posted: Mon Mar 16, 2015 8:42 am
by She

hi mark
i hope this link may help you out your problem.

http://stackoverflow.com/questions/16...


Calculate 2 boxes

Posted: Mon Mar 16, 2015 1:10 pm
by Mark7294305

Hi Support
Thanks for your reply.

I actually found the solution on the Tip calculator youtube vid and tweaked it as follows

var Box_A = Number(Apperyio("Box_A").val());
var Box_B = Number(Apperyio("Box_B").val());

var Box_C = Box_A + Box_B;

Apperyio('Box_C').text(Box_C.toFixed(2));
//Apperyio('Box_C').text('£' + Box_C.toFixed(2));

this works but the problem I now have is as I mentioned before I receive prices into Box A from a 3rd API. The results are received and displayed as "£3.50" for example into Box A. When adding Box A and Box B, Box C displays "NaN". If I then manually delete the "£" out of Box A it works fine. So the "£" is causing the "NAN" problem. How can I configure it to ignore the "£" and just add the "3.50"?


Calculate 2 boxes

Posted: Tue Mar 17, 2015 10:25 am
by Egor Kotov6832188

Hello Mark,

Please use
parseFloat(Apperyio("Box_A").val());
instead of
Number(Apperyio("Box_A").val());

Note: same for Box_b