Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

Two decimals in a input

Hello!
If I have a calculator, for example:

Two fields where the user (of the app) will input two numbers. When they click "Calculate" you get this: number1 / number2 = answer.

But if they for example write in "4 / 3", you will get: 1,333333333333333333-

My question is: How can I make the answer to: 1,334?
The javascript is in the Calculate-button:

var one, two
one = parseFloat(Appery("nu1").val());
two = parseFloat(Appery("nu2").val());

Appery("answe").val(one/two);

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Two decimals in a input

Hello Nicklas,

Hope this link will be useful: https://getsatisfaction.com/apperyio/...

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

Two decimals in a input

So I should be: Appery("answer").val(one/two).toFixed(2);

That didn't work :S

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

Two decimals in a input

But the link you showed me told me if I have 1, then I will get 1,00. But now I already have 1,3333333333333 and want: 1,334.

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

Two decimals in a input

Hi Nicklas,

Use the following code please:prevar res = one/two;
Appery("answer").val(res.toFixed(2));/pre

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

Two decimals in a input

Thank you very much! :)

Return to “Issues”