• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need simple division script and then format the results as a currency

New Here ,
Aug 20, 2020 Aug 20, 2020

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

Views

364

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 20, 2020 Aug 20, 2020

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

LATEST

Thanks a million - That did the trick!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines