Answered
Hi,
I'm trying to have a field that calculates the tax amount on four other fields and adds them. I want this rounded to two decimal points. Does anyone have a code/script that could help me with this? I have:
Code:
event.value = 0;
event.value = Math.round(this.getField("Amount-1").value * .051)+Math.round(this.getField("Amount-2").value * .051)+Math.round(this.getField("Amount-3").value * .051)+Math.round(this.getField("Amount-4").value * .051)
But I don't want it to round...
Thanks!
Dawn
There is only one parameter so one can not specify any decimal level.
[url=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Math/round]MDC Math.round method[/url]. So you are rounding each of your individually computed values to the nearest integer. And this in not what you want to do. If you adjust for the decimal point, there are still some issues with using the 'Math,round()' method.
One can use the Acrobat 'uti.printf()' method to obtain a more consistent rounding of a number. And since you are going to repeat this code, I would create a function to run the piece of code that performs the rounding.
George Kaiser