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

Creating a calculation field to add up interactive buttons

New Here ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

I've created a interactive pdf where the buttons reveal a number(which is a button itself)  os there a way to create a calculation field in acrobat so that what ever number appears is calculated as a total score. 

70F148D9-34B3-49FE-916F-F077515DB8EB.png

 

TOPICS
Acrobat SDK and JavaScript

Views

340

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 ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

Buttons don't have values. However, you can write a script that will check the visibility property of the button fields and if they are visible it will assume they have a value and use it to calculate a sum.

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
Community Expert ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

LATEST

Yes and No, as Try states, buttons don't have a value.

Do you have to use buttons?

If so then the values for the calculation could be stored in a JS object that matches the button name to a value. 

The best way to do this is to use group naming with the buttons,i.e., "Score.Button1" "Score.Button2" etc. then a generic script can be written to loop through the buttons, adding up the values for the ones that are visible. 

 

If the buttons can be replace with somthing that does have a value, like a field, then the same technique applies, only you don't need the JS object for mapping values. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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