Skip to main content
Participant
September 20, 2021
Answered

Acrobat Pro DC Dependent Dropdowns

  • September 20, 2021
  • 4 replies
  • 16518 views

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.

This topic has been closed for replies.
Correct answer Nesa Nurani

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.

4 replies

Participant
September 22, 2022

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?

 

 

Nesa Nurani
Community Expert
Community Expert
September 22, 2022

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

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
September 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.

Participant
August 21, 2024

this! *chef's kiss* I had gone through 1000 different answers and yours was so simple and perfect and thank you so much!!!!

try67
Community Expert
Community Expert
September 20, 2021

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

 

ls_rbls
Community Expert
Community Expert
September 20, 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 other discussions:

 

 

 

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