Skip to main content
Participant
October 12, 2017
Answered

Narrowing down the selection options of a dropdown based on the selected item in another dropdown

  • October 12, 2017
  • 1 reply
  • 757 views

Hello everyone,

i've been searching and trying a lot of things but it just doesn't seem to work for me, maybe because i just started using js in adobe.

In one dropdown menu i select (for example) a car type (VW, BMW etc.). Based on this, the selection possibilities of another dropdown(containing all types of car models for all car companies: golf, X3 etc.) shall be narrowed down to certain models(only VW e.g.).

Any suggestions?

I know how to get the content of the first dropdown via "getField" but hiding/unhiding or adding/removing in the second dropdown is the problem.

Thanks!

This topic has been closed for replies.
Correct answer try67

You can use the setItems method of the second field to define what options will be available in it.
For example:

this.getField("Model").setItems(["Golf", "X3"]);

If you're interested, I've developed a script that allow you do it without having to actually write any code. You can find it here:

Custom-made Adobe Scripts: Acrobat -- Create Dependent Dropdowns

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 12, 2017

You can use the setItems method of the second field to define what options will be available in it.
For example:

this.getField("Model").setItems(["Golf", "X3"]);

If you're interested, I've developed a script that allow you do it without having to actually write any code. You can find it here:

Custom-made Adobe Scripts: Acrobat -- Create Dependent Dropdowns

Participant
October 12, 2017

Thank you for the answer! I've seen similar solutions before but i just can not get js to set Items in a dropdown.   

Here i tried to simply add the values A and B to this dropdown but it won't work. What am i missing?

try67
Community Expert
Community Expert
October 12, 2017

You're missing a reference to the field, using the getField method. The "this" keyword usually refers to the document.

See my example above.