Copy link to clipboard
Copied
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!
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
You're missing a reference to the field, using the getField method. The "this" keyword usually refers to the document.
See my example above.
Copy link to clipboard
Copied
Thats it... i was so close to this solution, but i never managed to make a reference to the field. Thanks!