How can I roundup the answer to FieldA * FieldB to a product which is only 2 decimal points.
FieldB is a decimal number .001931
FieldA will always be a whole number with 2 decimal places.
I am trying to get if the answer is 5.235 to be 5.24 or if the answer is 5.231 to be 5.23
The calculation will be used in a fillable pdf.
You can specify this in the format of the field.
That's a dangerous approach. It might look like the value has been rounded up, but in fact it won't be, and if you use it in another calculation you might not get the results you expect. It's better to actually change the actual value, like this:
var v1 = Number(this.getField("FieldA").valueAsString); var v2 = Number(this.getField("FieldB").valueAsString); var v3 = v1*v2; event.value = v3.toFixed(2);
I edited the code because I noticed that even though you asked for "rouding up" in your examples you actually used regular rounding...
Thank you, but I am a little ignorant on this. If I put this into the custom java script calculation box, how can I get the Field that I am entering the custom calculation in to show the event.value?
Not sure what you mean... event.value is the new value that is assigned to the field.
Thank you but if I specify it in the format to 2 decimal places if the answer is 5.245 it will show on the form as 5.24 but will add as 5.25.