Skip to main content
Participant
September 19, 2016
Question

Many Calculations Causing Form to Pause

  • September 19, 2016
  • 1 reply
  • 217 views

I have created a 6 page QC form with rankings in Adobe Acrobat XI.  There are 20 sections with approx 11 questions in each section.  Each question is a dropdown with choices NA,1,2,3.  The associated export values are 0,3,3,3.  I have three calculations after each section - points possible, points earned, percentage.

points possible example:

event.value = this.getField("Misc1").value + this.getField("Misc2").value +this.getField("Misc3").value +this.getField("Misc4").value +this.getField("Misc5").value +this.getField("Misc6").value +this.getField("Misc7").value +this.getField("Misc8").value +this.getField("Misc9").value +this.getField("Misc10").value;

points earned: simple sum of fields in section (e.g. Misc1, Misc2, etc)

percentage example:

var numerator = +getField("Points earned_18").value;

var denominator = +getField("Points possible_18").value;

event.value = denominator !== 0 ? numerator / denominator : "";

I also have a total calculation for points possible, points earned, and percentage.  I have checked the calculation order and it is correct.  When I run the form I have to wait about 5 seconds when moving between each drop down field as the whole form is trying to calculate.  Any suggestions?

This topic has been closed for replies.

1 reply

Inspiring
September 19, 2016

You may have to optimize the calculations.

Scripting languages interpret each action when it is encountered and this done each time the script is encountered. This means each line is syntax checked, converted to execution tokens and then the tokenized object is executed. If one uses document level functions with or without parameters, then syntax checking and tokenization is done only once.

I would look at creating a sum function to sum the passed fields or the field values.

Also putting using one field to perform all the calculations  can speed things up by eliminating the need to read the code for each field that needs a calculation.

You might also improve the speed by using hierarchical field names so getting the field objects from the field names is reduced to getting the parent field and then creating an array of the children field objects instead of getting each field by name.