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

Drop Down SetItems() resets the list

Community Beginner ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Hi, everyone. I have a script in drop down field named "MODEL". It has two options is the list, G2500 and ONYX. Depending the selection, the script changes/sets the items of the list. When I try to select an item from the drop down list G1CDU other than first item, it goes back to the first item. So, I'm not able to select any other item.

this.getField("G1CDU").clearItems();
switch (event.value) {
case "G2500":
this.getField("G1CDU").setItems([
"Item 1",
"Item 2",
"Item 3"]);
break;

case "ONYX":
this.getField("G1CDU").setItems([
"Item 4",
"Item 5",
"Item 6"]);
break;

}

 Can you please help me in this regard?

TOPICS
Acrobat SDK and JavaScript

Views

97

Likes

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 , Oct 14, 2020 Oct 14, 2020

Try using this code as custom validation script of MODEL field:

var seti = this.getField("G1CDU");

if (event.value == "G2500") {
seti.clearItems();
seti.insertItemAt("Item3");
seti.insertItemAt("Item2");
seti.insertItemAt("Item1");
} else if ( event.value == "ONYX"){
seti.clearItems();
seti.insertItemAt("Item6");
seti.insertItemAt("Item5");
seti.insertItemAt("Item4");
}

Likes

Translate

Translate
Community Expert ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

Try using this code as custom validation script of MODEL field:

var seti = this.getField("G1CDU");

if (event.value == "G2500") {
seti.clearItems();
seti.insertItemAt("Item3");
seti.insertItemAt("Item2");
seti.insertItemAt("Item1");
} else if ( event.value == "ONYX"){
seti.clearItems();
seti.insertItemAt("Item6");
seti.insertItemAt("Item5");
seti.insertItemAt("Item4");
}

Likes

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
Community Beginner ,
Oct 14, 2020 Oct 14, 2020

Copy link to clipboard

Copied

LATEST

Thank you for your help. I tried the if statement like yours. I have figured it out.

I was using javascript in custom calculation script. Now, I'm using it in custom validation script and it is working fine.

Thank you.

Likes

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