Skip to main content
Known Participant
April 5, 2025
Answered

Adobe Prepare Form / 3rd Drop Down Menu dependent on selections for BOTH menus 1 and 2.

  • April 5, 2025
  • 3 replies
  • 1818 views

Hello Everyone,

I have a total of 3 Drop Down Menus and I’m trying to figure out what Javascript to write, and where, to make the 3rd menu’s options dependent on BOTH of the selections of menus 1 and 2.

 

My lists are more complicated, but if you can tell me what to write for the below example, I think I could figure out the rest.

 

Drop Down Menu 1 = “Food”

  • Always 3 choices: Liquid / Solid / Jello

 

Drop Down Menu 2 = “Inner-Pkg”

  • Always 3 choices: Carton / Bottle / Crate

 

Drop Down Menu 3 = “Outer-Box”

  • 6 total options, but I only want to see options dependent upon the entries under BOTH “Food” and “Inner-Pkg”
  • For example
    • If “Food” is “Liquid” and “Inner-Pkg” is “Carton”, there are only 2 options I want to see out of 6
    • If “Food” is “Liquid” and “Inner-Pkg” is “Bottle”, there are only 4 options I want to see out of 6
    • etc...

 

Each different combination of BOTH menus 1 and 2 would yield different packaging options to choose from in Drop Down Menu 3. Hoping this is an easy one. Thanks in advance for your help!!

Correct answer Nesa Nurani

@Stevie38923324rffg @lexon_4719 This will not work, if you used it like that as custom calculation script you won't be able to select any choice from 3rd dropdown it will keep reverting to first choice, you need to check for event.source :

if (event.source && (event.source.name=="Food" || event.source.name=="Inner-Pkg")) {
var food = this.getField("Food").value;
var inner = this.getField("Inner-Pkg").value;

if (food === "Liquid" && inner === "Carton") {
event.target.setItems(["Option A", "Option B"]);
} else if (food === "Liquid" && inner === "Bottle") {
event.target.setItems(["Option C", "Option D", "Option E", "Option F"]);
} else if (food === "Solid" && inner === "Crate") {
event.target.setItems(["Option G", "Option H"]);
} else {
event.target.setItems(["-- Select an option --"]);
}}

 

3 replies

Participant
April 21, 2025

You’re on the right track—this kind of conditional logic just needs a well-structured nested object in JavaScript and a custom calculation script for the third dropdown. I did something similar using getField("Dropdown3").setItems(...) based on both selected values, and it worked well once I mapped out every combo. Definitely doable with a little planning!

 

[Spam link removed]

Participant
April 5, 2025

You're close! The issue with using a Mouse Down script on the third dropdown ("Outer-Box") is that it resets the options every time the field is clicked — even if nothing changed.

✅ A better approach is to use a Calculation script in the third dropdown. Here's how to do it:

// JavaScript - Acrobat Dropdown Dependency
var food = this.getField("Food").value;
var inner = this.getField("Inner-Pkg").value;

if (food === "Liquid" && inner === "Carton") {
event.target.setItems(["Option A", "Option B"]);
} else if (food === "Liquid" && inner === "Bottle") {
event.target.setItems(["Option C", "Option D", "Option E", "Option F"]);
} else if (food === "Solid" && inner === "Crate") {
event.target.setItems(["Option G", "Option H"]);
} else {
event.target.setItems(["-- Select an option --"]);
}

This method ensures that "Outer-Box" only shows valid choices based on the combined selection of "Food" and "Inner-Pkg".

Let me know if you'd like help building the logic for all 9 combinations — happy to assist!

Cheers,
lex

Known Participant
April 6, 2025

Thanks Lex,

That worked! I'm always surprised and grateful for how quickly the Adobe community responds to these requests. You've saved me hours of frustration. Thank you, thank you!! 🙂

PDF Automation Station
Community Expert
Community Expert
April 5, 2025

Use the following Mouse Down action script in "Outer-Box":

var food=this.getField("Food").value;

var inner=this.getField("Inner-Pkg").value;

if(food=="Liquid" && inner=="Carton")

{event.target.setItems(["","A", "B", "C"])} else

if(food=="Liquid" && inner=="Bottle")

{event.target.setItems(["","D", "E", "F"])} else

//if ....etc.

{event.target.setItems([""])}

try67
Community Expert
Community Expert
April 5, 2025

This is not a good approach. It will reset the selection each time you click into that field.

The code should be placed either under the Validation scripts of the first drop-downs, or under a Calculation script, with an if condition added that checks which field triggered the event.

PDF Automation Station
Community Expert
Community Expert
April 5, 2025

--