Skip to main content
Known Participant
Jan 29, 2025 2:48 PM UTC
Answered

Need Help: Counting Number of Choices in Drop Down Box

Hi esteemed forum members:

I am a new user and would appreciate any help/guidance.

I have six drop down boxes (Choice1, Choice2..Choice6), each containing same list of 100 fruits. A user can select only one fruit from a drop down box and can, in total, select up to 6 fruits. My ask is how can I display the count of number of fruits selected (it could be a Java script or any other function).  Clarification: total fruits selected may range from one to six and the users may select same fruit from all boxes (i.e., a user may select one apple or six oranges or one watermelon and one raisin ).

Would appreciate any help.

PDF Automation Station
Community Expert
Jan 29, 2025 3:33 PM UTC

If they select the same fruit, does this count as 1 or 2?  What is the default value of your dropdowns?

4 replies

anil_BAuthor
Known Participant
Jan 30, 2025 3:08 PM UTC

Thanks a lot for providing the Javascript I have tested it and it works. I really appreciate your help.

Translate
PDF Automation Station
Community Expert
Community Expert
Jan 29, 2025 3:33 PM UTC

If they select the same fruit, does this count as 1 or 2?  What is the default value of your dropdowns?

Translate
anil_BAuthor
Known Participant
Jan 29, 2025 3:38 PM UTC

Those would be counted as two choices. The default value in each box is a blank.

Translate
PDF Automation Station
Community Expert
Community Expert
Jan 29, 2025 3:58 PM UTC

Enter the following custom calculation script in a text field where you want the count to appear:

var count=0;
for(var i=1;i<7;i++)
{
if(this.getField("Choice"+i).value!=this.getField("Choice"+i).defaultValue)
{count++}
}
event.value=count;
Translate