Skip to main content
New Participant
April 8, 2025
Answered

PDF doesn't calculate a value based on a drop down until another entry is made

  • April 8, 2025
  • 1 reply
  • 379 views

I have a text box ("PKG_PRICE") sest to calculate a value  based on a dropdown menu "PKG") (value is defined by OPTIONS>Export Value).  The "PKG_PRICE" text box properly displays the value once a drop down ("PKG") selection is made.  However, I have another calculation ("TOTALS") that should show totals based on a bunch of other values calculated throughout the form including the value from the "PKG_PRICE" text box.  The problem is "Totals" doesn't calculate the value from the "PKG_PRICE" text box (based on the "PKG" dropdown selection) UNTIL another random selection is made somewhere else in the pdf.  The "Totals" field is calculated with just the simple Calculate>Value is the Sum of...  The only custom script I have is the PKG_PRICE which is defined with the script:

 

var dropdownField = this.getField("PACKAGE");
var textField = this.getField("PKGPRICE");

if (dropdownField.value != "") {
textField.value = dropdownField.value;
} else {
textField.value = "";
}

 

Have I missed a line of code that would cause it to not caluclate properly?

Correct answer Bernd Alheit

Change the field calculation order

1 reply

Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
April 8, 2025

Change the field calculation order

New Participant
April 8, 2025

Shoot, tried it.  I wish it would've been that easy.   But it only lets you pick the fields to calculate from a "FIELD SELECTION" pop up window.  The selections appear to be in reverse alphabetical order.  I tried to force a change the order of them by changing the tab order in the FIELDS side bar window, but that had no affect on the FIELD SELECTION pop up window. 

 

I guess I can try to rename all the fields so that they're in alpahbetical order, but somehow that seems counterintuitive to how to organize a pdf form.

 

Got any other suggestions?  I really wish that first one would've worked.

New Participant
April 8, 2025

OMG- wait!  You actually WERE right!  I changed all the field names to force a selection order by naming them "01_*, 02_* , 03_* and so on. . ." and it totally worked!  Thank you SO much for your help!!!