Skip to main content
Known Participant
January 29, 2025
Answered

Need Help: Counting Number of Choices in Drop Down Box

  • January 29, 2025
  • 2 replies
  • 371 views

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.

Correct answer PDF Automation Station

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

2 replies

anil_BAuthor
Known Participant
January 30, 2025

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

PDF Automation Station
Community Expert
Community Expert
January 29, 2025

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

anil_BAuthor
Known Participant
January 29, 2025

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

PDF Automation Station
Community Expert
Community Expert
January 29, 2025

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;