javascript - display in decimal the total of 2 numbers -


I am trying to display 2 decimal points of 2 total numbers and display them by zero, but to the decimal point Do not count anyone want to find out this Thanks.

  function count () {var myBox1 = document.getElementById ('box1'). Values; Var myBox2 = document.getElementById ('box2'). value; Var Basic = Document. GetElementById ('Basic'); Var myResult = myBox1 * myBox2; BasicPay.value = myResult.toFixed (2); Document.getElementById ('Both'). Value = sum () - diff (); }  

This diff part is

  function diff () {var absent = document.getElementById ('absent'). Value; Var tardiness = document.getElementById ('tardiness') value; Var sss = document.getElementById ('SSS'). Values; Var pagibig = document.getElementById ('pagibig'). value; Var Fillholta = Document. GetElementById ('currently'). value; Var cashflow = document. GetElementById ('Casewevances'). value; Viral WithdlingTacks = Documents. Gate Element BIID ('Recording Blocks'). value; Var other = document. GetElementById ('other'). Values; Var result = purseInt (absent) + parsihinta + parseint (sss) + parsing (pajcib) + parseint (fillehith) + parsihant (casewevances) + parsihinta (wolingtax) + parsiat (other) || 0; If (! IsNaN (results) {document.getElementById ('totaldeductions'). Value = result.toFixed (2); Return result; }}  

This is part of the sum

  function sum () {var basic = document. GetElementById ('basicpay'). value; Var overtime = document.getElementById ('overtime'). value; Var Regular Holiday = Documents. Gate Element BIID ('Regular Holiday'). value; Variable Privileges = Documents. Gate Element BIID ('Specialholds'). value; Var permission = document. GetElementById ('permissible'). value; Var Month = Document. GetElementById ('Monthly'). value; Var other 1 = document. GetElementById ('others1'). Values; Var Results = Perseenton + Perspective (overtime) + Perseverant (regular holiday) + purseint (specialhole) + parseint (allowed) + parseint (monthpace) + parseint (other 1) || 0; If (! IsNaN (results) {document.getElementById ('totalgrosspay'). Value = result.toFixed (2); Return result; }}  

In your even () and def () function, you only work Integers with integers are only whole numbers, so will not maintain anything after a decimal point. To deal with decades, you have to use the javascript's parsphot () function. To give an example, in your Yoga () function you will change the calculation of results to look like the following:

  var result = parseflat (basicpay) + parsflow + parsflot ( Regular Holiday) + Personal Flow (specialhalled) + parseflat (allowed) + parsflot (months) + parsflot (other 1) || 0;  

This will keep decimal digits in numbers instead of rounding the whole numbers, as in parseInt ()


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -