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).
Can someone please help me with this?
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;
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.