Copy link to clipboard
Copied
Good Morning
I have searched all over and can't find anything that works so this is my first time posting on any forum anywhere!
I have 2 fields in my PDF form that I need to perform a division on then display the results as a currency in a third field.
I have a field called Total_Annual_Membership_Donation and a field called Pay_Periods. I need the result of the Total_Annual_Membership_Donation field divided by the Pay_Periods field value displayed in a field called zzz and I need the result formatted as currency with 2 decimal points. If I remove the formatting the simple calculation works fine (shown with many numbers after the decimal point) but as soon as I add currency formatting I get the error message about the field value not matching the formatting.
I also want to say the the Pay_Periods field is a drop down list with 10, 11 & 12 as the options and the total membership amount is divided by the number selected. There is also a blank value in the drop down list which is moved to the top so that when the user sees the form there is nothing shown in the drop down list.
Many Thanks
Amanda
Copy link to clipboard
Copied
Use the normal Number format with the currency option selected and enter this code as the custom calculation script of "zzz":
var v1 = Number(this.getField("Total_Annual_Membership_Donation").valueAsString);
var v2 = Number(this.getField("Pay_Periods").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/v2;
Copy link to clipboard
Copied
Thanks a million - That did the trick!