Skip to main content
Known Participant
March 19, 2017
Question

DropDown (ComboBox) with calculation.

  • March 19, 2017
  • 2 replies
  • 1735 views

First time user of Acrobat Pro DC.  I have a Combox (Drobdown) in a table with the name "classification." 20 rows. I want the user to select from two choices; "A" or "B".  On the same row of the table is an amount named "Amount."  At the bottom of the form, I have sub total of "A" and Subtotal of "B". If the user select "A' in the Dropdown, I want the amount Named "Amount" to go to subtotal "A"  If the user selects "B," I want the amount named Amount to go to subtotal "B."  Currently struggling with script.

This topic has been closed for replies.

2 replies

Jamesa47Author
Known Participant
April 2, 2017

Thank you TRY67 for resolving my calculation issue.

try67
Community Expert
Community Expert
March 19, 2017

You left out some key information here. Are the field names "classification.1", "classification.2", "classification.3", "Amount.1", "Amount.2", "Amount.3", etc.? If so then you can use this code as the custom calculation script for the Total A field:

var total = 0;

for (var i=1; i<=20; i++) {

    if (this.getField("classification."+i).valueAsString=="A")

          total+=Number(this.getField("Amount."+i).valueAsString);

}

event.value = total;

Just replace =="A" in line #3 with =="B" for the Total B field.

Jamesa47Author
Known Participant
March 20, 2017

Restate:

I want the user to select in a table from two DropDown choices; "A" or "B" items listed under Field name "classification_1.  Field Names continues in each row; classification_2, Classification_3 and so on...On the same row of the table is an amount named "Amount_1, Amount _2, Amount_3 and so on.

If the user selects Classification_1 and Item "A" in the Dropdown, Field name Amount is Amount_1

If the user selects Classification_1 and Item "B" that amount goes to field name Amount_1

At the bottom of the form, I have named fields "sub total A" which is the sum of all of the field names "Amount_1, _2, _3,...." and the field named Classification_1, _2, _3, ... "A." listed item Dropdown A

At the bottom of the form, I have named fields "sub total B" which is the sum of the same field names "Amount_1, _2, _3,...." but the field named Classification_1, _2, _3, ... "B." listed item Dropdown B.

This continues in the tables for all of the fields names in the table.

try67
Community Expert
Community Expert
March 20, 2017

I don't really follow... Did you create two sets of Amount fields?