Search code examples
javascriptpdfinteractiveacrobat

Custom calculations in an interactive PDF scale/checklist?


I am looking to achieve a few custom calculations within a interactive PDF scale/checklist.

I've attached an annotated image attached to better explain the type of calculations I'm looking to do, but here is a written summary too:

1.) Have a specific field sum the # of checkboxes that have been checked in the same column (ie: if 2 of 4 checkboxes have been checked, the sum field would populate with the number 2)

2.) Have a field show the results of the sum of a different field multiplied by a specific value (ie: Sum of "Field A" x 2 = "Field B")

Any help would be greatly apreciated!

Thank you 🙂

I'm completely unsure of where to even start!


Solution

  • To 1: Set up a list (aka array) of the field names of the checkboxes. When evaluating, loop through the names and count the number of times the value is Off, then subtract this number from the number of checkboxes.

    Reason: The field value of an unchecked checkbox field is always Off. The value when checked is unknown (because you can chose it).

    To 2: I am not quite sure whether I understand what you want to do. But if it is writing the value of field A times a factor into field B, you could do this by adding the following script to the Calculate event of field B:

    event.value = this.getField("Field A").value x 2 ;
    

    And that should do it.