I have the following code that is supposed to do a sum in a pdf.
var sum = 0.0;
var f1 = this.getField("price");
var temp = parseFloat(f1.value);
sum = temp;
var total = this.getField("total");
if(sum > 0)
{
total.value = sum;
}
else
{
total.value = "";
}
But if the input is
18.31
my total is
18
EDIT: I also tried
console.println(f1.value);
But the value of f1.value is only 18.
EDIT: this is running in the javascript interpreter in the foxit pdf reader.
EDIT: I have confirmed there is a bug in the foxit reader javascript interpreter.
That's because
parseFloat()
convertsf1.value
(if it is a number) into a string, rounding it along the way, depending on what thetoString()
method of the object returns.Try without it.
http://www.jibbering.com/faq/faq_notes/type_convert.html#tcParseFl