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

Change multiple dropdown menus based on value of first dropdown

Community Beginner ,
Mar 07, 2023 Mar 07, 2023

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.

TOPICS
Edit and convert PDFs , How to , JavaScript , PDF forms
5.5K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 07, 2023 Mar 07, 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.

View solution in original post

Translate
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 ,
Mar 07, 2023 Mar 07, 2023

https://acrobatusers.com/tutorials/js_list_combo_livecycle/

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

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

Translate
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 ,
Mar 07, 2023 Mar 07, 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.

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 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.

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

I figured it out. My dropdown titles didn't match the code. All good now. Thank you so much.

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

I want the same effect for the dropdown menu but I don't work.


I got two dropdown called "d" and "e" which both of them contain three options in it.

And I want to show the "e" option based on the options in "d" menu

 

 

 

726EFA4A-D9E0-4769-BC91-E00418C212CB.jpegexpand image

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

It also doesn't work if I use this script 

 

33F2B992-5E4D-4235-AE20-08D8F5962A42.jpegexpand image

 

Translate
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 ,
Mar 07, 2023 Mar 07, 2023

In the first photo, you are missing the second curly bracket at the 'else' part.

In the second photo, you are missing the quote at 'Item 3'.

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

It also doesn't work. Can you do the corrections for me?

 

that When I select option "a" on drop down list called "drop1",  another drop down list "drop2" will automatically appear option "b".

 

There are three options in each dropdown 

Translate
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 ,
Mar 07, 2023 Mar 07, 2023

Use this as validation script of "drop1" field:

var d2 = this.getField("drop2");
if(event.value == "a")
d2.setItems(["a1"]);
else if(event.value == "b")
d2.setItems(["b1"]);
else if(event.value == "c")
d2.setItems(["c1"]);
else
d2.clearItems();

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

I have applied this.

However, after I select from drop1, all the options from drop2 are disappeared 

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

image.jpgexpand image

 

Translate
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 ,
Mar 07, 2023 Mar 07, 2023

Is field name "e" or "drop2"?

Can you share file?

Translate
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 Beginner ,
Mar 07, 2023 Mar 07, 2023

538F3398-3248-4ACD-AC55-FB93A4097CBB.jpegexpand image

C8B4D284-236F-49B8-B0D1-74128D78554C.jpegexpand image

  

Translate
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 ,
Mar 08, 2023 Mar 08, 2023

What is the issue exactly?

Did you use script as validation or calculation?

Translate
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 Beginner ,
Mar 08, 2023 Mar 08, 2023

  

after I select from the left dropdown, the options of right drop down disappeared.

6F1E44CF-87A1-475D-BE1D-B98766D72C8B.jpegexpand image

00A7A1FA-7E2A-4C1F-B98F-E408B3FD54CF.jpegexpand image

 

75840833-5F3A-42AB-8E56-59ADA05A69EE.jpegexpand image

 

 

Translate
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 ,
Mar 08, 2023 Mar 08, 2023

Use script as 'Validate'.

Translate
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 Beginner ,
Mar 08, 2023 Mar 08, 2023

 I applied here

08F6CEAD-7FEF-47ED-9750-173BD6354B2B.jpegexpand image

Translate
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 ,
Mar 08, 2023 Mar 08, 2023

Then please share your file with us.

Translate
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 Beginner ,
Mar 08, 2023 Mar 08, 2023
Translate
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 ,
Mar 09, 2023 Mar 09, 2023

Try the atachment.

Translate
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 ,
Mar 09, 2023 Mar 09, 2023
LATEST

Tick the box that says "Commit selected value immediately" (under Properties - Options) and it will change as soon as you make a selection in the first field.

Translate
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 Beginner ,
Mar 08, 2023 Mar 08, 2023
Translate
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