Skip to main content
New Participant
March 7, 2023
Answered

Change multiple dropdown menus based on value of first dropdown

  • March 7, 2023
  • 2 replies
  • 6422 views

I have four dropdown menus. "Name", "Title", "Competency", "Number". What I want to do is to have the values in the last three to change based on which "Name" I select. I have tried just about every code and script I could find but doesn't seem to work with the newest version of Acrobat Pro DC. Thank you.

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

As 'validation' script of "Name" field use this:

var d1 = this.getField("Title");
var d2 = this.getField("Competency");
var d3 = this.getField("Number");

if(event.value == "Name 1"){
d1.setItems(["Title1","Title2"]);
d2.setItems(["Competency1","Competency2"]);
d3.setItems(["Number1","Number2"]);}

else if(event.value == "Name 2"){
d1.setItems(["Title3","Title4"]);
d2.setItems(["Competency3","Competency4"]);
d3.setItems(["Number3","Number4"]);}

else{
d1.clearItems();
d2.clearItems();
d3.clearItems();}

Just change items to what you need them to be and add more 'else if' conditions (before last 'else') if needed.

2 replies

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
March 7, 2023

As 'validation' script of "Name" field use this:

var d1 = this.getField("Title");
var d2 = this.getField("Competency");
var d3 = this.getField("Number");

if(event.value == "Name 1"){
d1.setItems(["Title1","Title2"]);
d2.setItems(["Competency1","Competency2"]);
d3.setItems(["Number1","Number2"]);}

else if(event.value == "Name 2"){
d1.setItems(["Title3","Title4"]);
d2.setItems(["Competency3","Competency4"]);
d3.setItems(["Number3","Number4"]);}

else{
d1.clearItems();
d2.clearItems();
d3.clearItems();}

Just change items to what you need them to be and add more 'else if' conditions (before last 'else') if needed.

New Participant
March 7, 2023

So, I put this in the custom validation script in the "Name" dropdown. Do I put the actual name in the script, and the "Title" I want associated with it, so on, etc.? I am really bad at this. Nothing is working.

Thom Parker
Community Expert
March 7, 2023
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
New Participant
March 7, 2023

I'm sorry, but none of that makes any sense. Can you please explain in Crayon? I need this dumbed down... a lot.