Tuesday, 15 June 2010

javascript - Calculator with math.round with 2 decimal -


I have to put a calculator online for the client and I have to face a problem with math. Here is my code:

  function calc (type) {if (type == "terre") {var lo = parseFloat (document.getElementById ("terre_lo"). Value); Var la = parseFloat (document.getElementById ("terre_la"). Value); Var pr = parseFloat (document.getElementById ("terre_pr") value); Var res = lo * la * (PR / 12) / 27; Document.getElementById ("terre_re"). Internal HTML = MathRed (race * 100) / 100; Tmp = monastery Field (race * 100) / 100; Paillis = Math Plain ((res * 30) / 100) + res; If (TMP <(res * 0.30) / 100) {paillis; } Document.getElementById ("res_paillis"). InnerHTML = policies; }} & Lt; / Script & gt;  

Everything is working fine but I need to do math for 30% result and round with 2 decimals. In this way 1.32 my problem is that it revolves evenly with the small values ​​as the first result. I have to calculate the fourth (foot) x length (feet) x depth (inches), this will keep me 30% of this result. With the small value it is the same round as the result. I'm not a programmer, I'm a web designer, so I'm broad;)

You can see the calculator page here

Working code:

  function calc (type) {if (type == "terre") {var lo = parseFloat (document getElementById ("terre_lo") value). Var la = parseFloat (document.getElementById ("terre_la"). Value); Var pr = parseFloat (document.getElementById ("terre_pr") value); Var res = lo * la * (PR / 12) / 27; Document.getElementById ("terre_re"). Internal HTML = MathRed (race * 100) / 100; Tmp = monastery Field (race * 100) / 100; Paillis = (res * 30) / 100 + res; If (TMP <(res * 0.30) / 100) {paillis; } Document.getElementById ("res_paillis"). InnerHTML = Mutt Field (Pillis * 100) / 100;  

No comments:

Post a Comment