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

Javascript Help for calculation in a fillable PDF

Community Beginner ,
Jan 10, 2020 Jan 10, 2020

Hi! I am needing some help. I am not Javascript savvy .. 
I am creating a fillable PDF in Adobe Acrobat PRO DC. I am needing to calculate one column so that everything in the 15 rows(milage 54milerow1, milage 54milerow2, milage 54milerow3, etc) is multiplied by .54 and then totaled at the bottom in Sum16... Can someone help me with this?expense milage.pngexpand image

TOPICS
Edit and convert PDFs , PDF forms
2.8K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 10, 2020 Jan 10, 2020

You can use this code as the custom calculation script of Sum16:

 

var total = 0;
for (var i=1; i<=15; i++) total+=Number(this.getField("Milage 54mileRow"+i).valueAsString);
event.value = total * 0.54;

View solution in original post

Translate
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 ,
Jan 10, 2020 Jan 10, 2020

You can use this code as the custom calculation script of Sum16:

 

var total = 0;
for (var i=1; i<=15; i++) total+=Number(this.getField("Milage 54mileRow"+i).valueAsString);
event.value = total * 0.54;
Translate
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 Beginner ,
Jan 10, 2020 Jan 10, 2020

Thank you! Is there anything I need to change/add in this? Or should I be able to just copy and paste? I went into the properties of Sum16, went to calculate and pasted the code under custom calculation script but it's not doing anything. 

Translate
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 ,
Jan 10, 2020 Jan 10, 2020

You don't need to change anything. However, you do need to change the value of one of the fields for it to "kick in".

If it's still not working press Ctrl+J and check if there are any error messages in the window that opens.

Translate
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 Beginner ,
Jan 10, 2020 Jan 10, 2020

This is what I am getting back. 

 

properties.pngexpand imageCtrl+J.pngexpand image

Translate
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 ,
Jan 10, 2020 Jan 10, 2020

That means your fields are not named consistently, so trying to access one of them is returning an error.

Translate
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 Beginner ,
Jan 10, 2020 Jan 10, 2020
LATEST

Oh, I figured it out ... Thank you so much for all your help! I truly appreciate it!

Translate
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