• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Oct 12, 2017 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!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

478

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
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 12, 2017 Oct 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

Votes

Translate

Translate
Community Expert ,
Oct 12, 2017 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

Votes

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
community guidelines
New Here ,
Oct 12, 2017 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?

Votes

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
community guidelines
Community Expert ,
Oct 12, 2017 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.

Votes

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
community guidelines
New Here ,
Oct 12, 2017 Oct 12, 2017

Copy link to clipboard

Copied

LATEST

Thats it... i was so close to this solution, but i never managed to make a reference to the field. Thanks!

Votes

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
community guidelines