Acrobat Pro DC Dependent Dropdowns

New Here ,
Sep 19, 2021 Sep 19, 2021

Copy link to clipboard

Copied

I have 2 dropdown lists on my pdf form named, "Category" and "Items".  I need to make the "Items" List dependent on the "Category" List. The "Category" List items are "Fruits", "Veggies", "Other".  If you select "Fruits", then the "Items" list would contain a list of fruits.  If you select "Veggies", then the "Items" list would contain a list of vegetables, etc.

 

I understand that I need a Javascript to make this happen, but alas, I do not know how.

 

Your help is appreciated.

TOPICS
How to , JavaScript , PDF forms

Views

597

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

correct answers 2 Correct answers

Community Expert , Sep 19, 2021 Sep 19, 2021

In this link PDF Form JavaScripts Dependent Dropdown Menus the video shows how to create dependent dropdown menus using vegetables and fruits as an example.

 

There are different ways you can achieve the same results with JavaScript scripting,  and I've seen this answeered before many times in these support forums and outside these forums.

 

See another useful way published by ACP Joel Geraci in this other link: Acrobat Javascript: Change list values based on another list 

 

See these othe

...

Likes

Translate

Translate
Community Expert , Sep 20, 2021 Sep 20, 2021

In "Category" field->properties->options tab tick 'Commit selected value immediately', use script in "Category" field as validation:

var f = this.getField("Items");
switch(event.value){
case "Fruits":
f.setItems(["Banana","Apple","Lemon","Orange"]);
break;
case "Veggies":
f.setItems(["Tomato","Cabbage"]);
break;
case "Other":
f.clearItems();}

"Other" choice will clear items from "Items" field, if you want something else under "Other" choice let me know.

Likes

Translate

Translate
Community Expert ,
Sep 19, 2021 Sep 19, 2021

Copy link to clipboard

Copied

In this link PDF Form JavaScripts Dependent Dropdown Menus the video shows how to create dependent dropdown menus using vegetables and fruits as an example.

 

There are different ways you can achieve the same results with JavaScript scripting,  and I've seen this answeered before many times in these support forums and outside these forums.

 

See another useful way published by ACP Joel Geraci in this other link: Acrobat Javascript: Change list values based on another list 

 

See these other discussions:

 

 

 

You may also want to dig more in these tutorials from ACP Thom Parker:

 

 

 

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
community guidelines
Community Expert ,
Sep 20, 2021 Sep 20, 2021

Copy link to clipboard

Copied

If you're interested, I've developed a (paid-for) tool that allow you to set it up easily and quickly, without having to write any code. You can find it here: https://www.try67.com/tool/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
community guidelines
Community Expert ,
Sep 20, 2021 Sep 20, 2021

Copy link to clipboard

Copied

In "Category" field->properties->options tab tick 'Commit selected value immediately', use script in "Category" field as validation:

var f = this.getField("Items");
switch(event.value){
case "Fruits":
f.setItems(["Banana","Apple","Lemon","Orange"]);
break;
case "Veggies":
f.setItems(["Tomato","Cabbage"]);
break;
case "Other":
f.clearItems();}

"Other" choice will clear items from "Items" field, if you want something else under "Other" choice let me know.

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
community guidelines
New Here ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

Hi! I used the below formula posted by Nesa and it worked however whenever I select something in the dropdown 2 after selecting an option from the first dropdown 1, it keeps defaulting to the first value listed for dropdown 2. How do I get rid of this default?

 

 

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
community guidelines
Community Expert ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

LATEST

Use script in 'validation' tab, not 'calculation'.

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