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

autopopulate dropdown list based on dropdown choice

Explorer ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

I need to autopopulate a drop down list  based an a choice in anothe drop down list, for exemple:

In "Dropdown1" someone choose "Portugal" I need that appears in my "Dropdown2" -» "2220"; "2300"; "2523", for example, I´ve see the fallow code but not sure is this result for me, some help please? I´m using Acrobate PRO DC

 

function updateDropdown() {

var f1 = getField("DropdownList1");

var f3 = getField("DropdownList2");

var s1 = event.target === f1 ? event.value : f1.valueAsString;

if (s1 === " ") {

f3.clearItems();

} else {

f3.setItems([" ", s1, s2]);

}

}

Views

459

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 1 Correct answer

Community Expert , Jul 04, 2022 Jul 04, 2022

If the second field is called "Dropdown2" the basic code to do it is the following (to be used as the custom Validation script of the first drop-down):

 

if (event.value=="Portugal") this.getField("Dropdown2").setItems(["2220", "2300", "2523"]);

Votes

Translate

Translate
Community Expert ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

If the second field is called "Dropdown2" the basic code to do it is the following (to be used as the custom Validation script of the first drop-down):

 

if (event.value=="Portugal") this.getField("Dropdown2").setItems(["2220", "2300", "2523"]);

Votes

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
Explorer ,
Jul 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

Works just perfectly, much more simple that I thought, thanks a lot Try67.

Votes

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
Explorer ,
Jul 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

I have put the fallow code with more than 1 option, but the code only assume Portugal (first option), when I choos Germany in my first dropdown, only appears Portugal options, what I did wrong?

 

if (event.value=="Portugal") this.getField("Dropdown3").setItems(["Choose CC","2000 OVA/CUC"]);
if (event.value=="Germany") this.getField("Dropdown3").setItem(["1000 K.Automotive Holding", "1100 ATT", "1200 ISE","1300 HAG"]);

 

Votes

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
Explorer ,
Jul 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

LATEST

OK, I already know why it doesn´t works, it´s missing a "s" in Germany line code in "SetItem", wotks now just fine, thanks a lot once again

 

Votes

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