Skip to main content
Participant
Oct 12, 2017 7:27 AM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Oct 12, 2017 8:48 AM UTC

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

4 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Oct 12, 2017 8:48 AM UTC

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

Translate
Participant
Oct 12, 2017 11:21 AM UTC

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?

Translate
try67
Community Expert
Community Expert
Oct 12, 2017 11:53 AM UTC

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

See my example above.

Translate