Skip to main content
Participant
November 9, 2017
Question

show/hide dropdown fields based on user choice

  • November 9, 2017
  • 1 reply
  • 659 views

I am creating an adobe form and have 4 dropdown fields [text1, text2, text3, text4] that are populated by another dropdown box [main_text].  The fields text1, text2, text3, text4 have the same options [option1, option2, option3, option4].  Is there a way to hide an option when it is selected in one of the dropdown boxes?  For instance if a user chooses option 1 in the dropdown box called text1 can that option be hidden in the other 3 dropdown boxes [text2, text3, text4].  Then the same thing when the user chooses an option for text2 and so on.  Eventually by the time they get to text4 there should be only 1 option left for them to choose.

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
November 13, 2017

Hello Susan, Yes there is a way.  However, this is a complicated JS intensive thing, and has to be properly managed.

First, the main list has to be stored somewhere global. Then you need a document level function that is called each time a selection is made. The purpose of the function is to go over every list and collect all the selections, Then make a copy of the main list that does not include the current selections. Then apply this copy to each of the dropdowns.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
November 14, 2017

Thank you, it sounds a bit more complicated than I was expecting.

Thom Parker
Community Expert
Community Expert
November 14, 2017

It's complicated because it involves more than one field. but the concept is very simple.

** On the Commit Event

1. Get all selected values

2. Remove from Master List of items

3. Set each field to modified item list

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often