Expand my Community achievements bar.

Why would Calculation calculate like this????????

Avatar

Level 2

I have a form with a table and a text box

The table has 9 columns, and 15 rows. In the table I have debit and credit columns. These columns are setup as numeric with float selected.

In the calculate event of the non-table text box I have a JavaScript that adds the credit rows and puts in a var cred, adds debit rows and puts in a var deb. it looks like this

var cred = xfa.resolveNode("#subform[1].Table1.Row1.Credit_Row1").rawValue + xfa.resolveNode("#subform[1].Table1.Row2.Credit_Row2").rawValue;

var deb = xfa.resolveNode("#subform[1].Table1.Row1.Debit_Row1").rawValue + xfa.resolveNode("#subform[1].Table1.Row2.Debit_Row2").rawValue + xfa.resolveNode("#subform[1].Table1.Row3.Debit_Row3").rawValue;

I then use an if statement to see if credits == debits, if they do then the text box value is “Balanced”, if they don’t then the text box value is “Not Balanced”. It looks like this.

if (cred  == deb){

    this.rawValue = "Balanced"

}else {

    this.rawValue = "Not Balanced"

}

This code works until the user types a .59 into debit row 1, .31 into debit row 2, and .90 into credit row(or something similar). In this scenario var deb should = .90, var cred should = .90, making the field show balanced. Instead var cred is showing 0.8999999999999999, and var deb is showing 0.90, making it show not balanced.

Is there any idea what may be causing this to happen?

0 Replies