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

Using one Dropdown list to Populate another works, but can't make selections in second Dropdown

New Here ,
Nov 28, 2017 Nov 28, 2017

I was using the switch script in a custom calculation script in a dropdown to populate a 2nd dropdown (which works correctly), but I can't actually make a selection in the 2nd dropdown list. The list is made and I can click on it to see the populated options, but clicking off the dropdown list after selecting an option besides the first causes it to revert back to the default choice. I assume it has something to do with the list being re-populated after making my choice, but I have no idea on how to stop it.

TOPICS
Acrobat SDK and JavaScript , Windows
546
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 ,
Nov 28, 2017 Nov 28, 2017

Don't use a calculation script for this.

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
New Here ,
Nov 28, 2017 Nov 28, 2017

What do you suggest I use instead?

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
LEGEND ,
Nov 28, 2017 Nov 28, 2017

The first dropdown calculation script gets triggered whenever any field value changes, so when you make a selection in the second dropdown, it gets triggered and resets the second dropdown. Without knowing more about how the form is intended to work, it's hard to give a specific recommendation. Using a custom validation or keystroke script instead in the first dropdown would probably be better. It would probably help if you posted the calculation script you're using now.

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
New Here ,
Nov 28, 2017 Nov 28, 2017

Here's an example:

switch (event.value) { 

    case "1":

        this.getField("Sub1").setItems([""]);

        break;

    case "2":

        this.getField("Sub1").setItems(["","1","2","3"]); 

        break;

    case "3":

        this.getField("Sub1").setItems([""]); 

        break;

     case "4":

        this.getField("Sub1").setItems([""]); 

        break;

     case "5":

        this.getField("Sub1").setItems(["","1","2","3"]); 

        break;

          }

The Sub1 dropdown will populate a blank space, 1, 2, and 3 when I select 2 on the first dropdown, but like I said, It'll go back to the blank spot when I click off. How do you suggest I change my script so that it works in custom validation or a keystroke script?

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 ,
Nov 28, 2017 Nov 28, 2017
LATEST

Just move it as-is to be a custom validation script.

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