Get total from dropdown boxes

New Here ,
Jul 07, 2018 Jul 07, 2018

Copy link to clipboard

Copied

Hello

I have a PDF form that has dropdown boxes in a column that has a text box at the bottom that I want to display a total sum based on the letter showing in the dropdown boxes.  If an "X" is displayed in the dropdown box, then I want it to be counted and included in the total at the bottom.  In the image below there are 4 "X's" displayed in the dropdown boxes and the total at the bottom of the boxes has "4".

I want to add a javascript to the "Total Hits" field that automatically adds the number of "X's" displayed in the dropdown boxes.  I will do the same thing for each Table (I, II, III, and IV).

Hits.JPG

Can someone please help me with this?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

106

Likes

translate

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
Most Valuable Participant ,
Jul 08, 2018 Jul 08, 2018

Copy link to clipboard

Copied

Let's say the names of the drop-down fields are "Dropdown1" to ""Dropdown7".

You can use this code to perform the calculation:

var fields = ["Dropdown1", "Dropdown2", "Dropdown3", "Dropdown4", "Dropdown5", "Dropdown6", "Dropdown7"];

var total = 0;

for (var i in fields) {

    if (this.getField(fields).valueAsString=="X")

        total++;

}

event.value = total;

Likes

translate

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
New Here ,
Jul 08, 2018 Jul 08, 2018

Copy link to clipboard

Copied

try67 ,

Thank you so much!!  Your script worked like a charm and did exactly what I needed it to do.  I really appreciate your help.

Likes

translate

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