Expand my Community achievements bar.

Creating a dropdown list which is depending on the selections from 2 other dropdown lists

Avatar

Level 1

Hi,

I'm new to LiveCycle and JavaScript and I was hoping someone could help me with this form I am creating.

This is what I want it to do:

I have a dropdown list named 'Area' which drops down to 3 options.  Once the form filler selects an area, they will then select an option from dropdown list 2 which is named 'Brand'  (there is up to 5 options), I then I want dropdown list 3 named 'Address" to have all of the address of the area and brand selected.

Is this possible?

Thankyou for your help!!

1 Reply

Avatar

Level 5

Hi,

here is an example for three dropdowns with dependencies.

You have to copy this code in the change-event of the fist dd:

Number and Letter are the entries in my example in the first dd. You have to adapt to your entries. Then you have your object names change in the script.

dd.jpg

DropdownListe2.addItem("123"); - this phrase you could use several times (in your example 5x for the second dd)

switch (xfa.event.newText)

{

    case "Number":

        DropdownListe2.clearItems();

        DropdownListe3.clearItems();

        DropdownListe3.rawValue = null;

        DropdownListe2.addItem(" ");

        DropdownListe2.addItem("123");

        DropdownListe2.addItem("456");

        DropdownListe2.selectedIndex = 0;

        break;

    case "Letter":

        DropdownListe2.clearItems();

        DropdownListe3.clearItems();

        DropdownListe3.rawValue = null;

        DropdownListe2.addItem(" ");

        DropdownListe2.addItem("A");

        DropdownListe2.addItem("B");

        DropdownListe2.selectedIndex = 0;

        break;

    default:

        break;

}

This code you have to copy in the change-vent from the second dropdown:

switch (xfa.event.newText)

{

    case "123":

        DropdownListe3.clearItems();

        DropdownListe3.addItem(" ");

        DropdownListe3.addItem("123_aa");

        DropdownListe3.addItem("123_bb");

        DropdownListe3.selectedIndex = 0;

        break;

    case "456":

        DropdownListe3.clearItems();

        DropdownListe3.addItem(" ");

        DropdownListe3.addItem("456_aa");

        DropdownListe3.addItem("456_bb");

        DropdownListe3.selectedIndex = 0;

        break;

    case "A":

        DropdownListe3.clearItems();

        DropdownListe3.addItem(" ");

        DropdownListe3.addItem("A_1");

        DropdownListe3.addItem("A_2");

        DropdownListe3.selectedIndex = 0;

        break;

    case "B":

        DropdownListe3.clearItems();

        DropdownListe3.addItem(" ");

        DropdownListe3.addItem("B_1");

        DropdownListe3.addItem("B_2");

        DropdownListe3.selectedIndex = 0;

        break;

    default:

        break;

}

Here you will find an example:

https://workspaces.acrobat.com/?d=WjPa976zd1Ekdahx9r9kUw

Hope it will helps you,

Mandy