Result of the calculation were separated to the whole and decimal, number not rounding correctly

I have 2 fields as a result of sharing: the whole and decimal number (1 decimal place). I Math.floor the result to get the whole number and everything is fine until I hit a case where the result is 92,97.

This should give "93" in the whole of the field and '0' in the decimal field, instead it gives me '92' and '10' (even though I'm only hosting 1 character in the field).

How can I get the '93' and '0' in the following code?

fieldLVEDV = this.getField("LVEDV").value;

fieldBSA = this.getField("BSA").value;

If (fieldLVEDV! = "" & & fieldBSA! = "") {}

totalLVEDV = this.getField("LVEDV").value + ((this.getField("LVEDVDec").value)/10);

calculation = (totalLVEDV / fieldBSA);

calculationDecimal = calculation;

partWhole = Math.floor (calculation);

if(partWhole <0) {partWhole =' ' ;}}

this.getField("Index").value = partWhole;

this.getField("IndexDecimal").value = Math.round (10 *(calculationDecimal-partWhole));

{If (this.getField("IndexDecimal").value = '10')

{

this.getField("Index").value = partWhole + 1;

this.getField("IndexDecimal").value = "0".

}}

} else {}

this.getField("Index").value = "";

this.getField("IndexDecimal").value = "";

}

I thought I'd add the blue part would do the job, but obviously it did not work.

Ah, your problem is that you do not use the correct comparison operator. To check if two values are equal, the operator is "==" not not "=". Using "=", you assign the value 10 to the field which you then pass in 0 a few lines down. Use 'is' and things should work correctly.

Tags: Acrobat

Similar Questions

Maybe you are looking for