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

New Here ,
Oct 12, 2017

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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

113

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

New Here ,
Oct 12, 2017

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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

114

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 12, 2017 0
Most Valuable Participant ,
Oct 12, 2017

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2017 0
New Here ,
Oct 12, 2017

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2017 0
Most Valuable Participant ,
Oct 12, 2017

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2017 0
New Here ,
Oct 12, 2017

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2017 0