Expand my Community achievements bar.

SOLVED

Help needed on linking drop down boxes

Avatar

Former Community Member

Hello there,

I am using adobe life cycle designer 8 to make forms. These forms are usesd to collect information on persons working in the healthcare industry.

I want to use drop down lists that are "connected". Depending on the choice made in the first dropbox, the user will get new options in the second dropbox.

Example:

Dropbox 1

Values

- value 1

- value 2

- value 3

Dropbox 2

If user choses value 1, they can chose the following values in dropbox 2:

- Value A

- Value B

If user choses value 2, they can chose the following values in dropbox 2:

- Value C

- Value D

If user choses value 3, they can chose the following values in dropbox 2:

- Value E

- Value F

I have been puzzeling for a while, but cannot find the solution for this.

THank you in advance

Daniel

1 Accepted Solution

Avatar

Correct answer by
Level 5

I make the pdf compatible for ES 8. Now it should be work. https://workspaces.acrobat.com/?d=qBsk3hERFH2RcSn5vQ5rBg

When the script doesn't work you have to check

script language - javascript

objectname - is your objectname the same as (when your dd called dd_choice2 or dropbox_2, then you have to change the script)

case "123":

        dropbox_2.clearItems();

        dropbox_2.addItem("Please select a value");

        dropbox_2.addItem("456");

        dropbox_2.addItem("789");

        dropbox_2.selectedIndex = 0;

        break;

The behaviour is correct when you copy them.

You select "123"

     2. DD "456" and "678"

You select "456"

     2. DD "123" and "678"

You select "678"

     2. DD "456" and "678"

Please give feedback tomorrow if it's work.

Kind regards Mandy

View solution in original post

7 Replies

Avatar

Level 5

Hi,

1. You create the first dropdown, for example with the following entries:

    123

    456

    789

2. You create a second dropdown which is empty.

3. Then you have to copy the follwoing script in the change-event of the first dropdown:

switch (xfa.event.newText)

{

    case "123":

        DropdownListe2.clearItems();

        DropdownListe2.addItem("Please select a value");

        DropdownListe2.addItem("456");

        DropdownListe2.addItem("789");

        DropdownListe2.selectedIndex = 0;

        break;

    case "456":

        DropdownListe2.clearItems();

        DropdownListe2.addItem("Please select a value");

        DropdownListe2.addItem("123");

        DropdownListe2.addItem("789");

        DropdownListe2.selectedIndex = 0;

        break;

    case "789":

        DropdownListe2.clearItems();

        DropdownListe2.addItem("Please select a value");

        DropdownListe2.addItem("123");

        DropdownListe2.addItem("456");

        DropdownListe2.selectedIndex = 0;

        break;

    default:

        break;

}

That's all.

In your case you  have to change "123", "345", "678" in "value 1", "value 2", "value 3".

In the first case "value 1" you have to change in the first case "value 1": the DropdownListe2.addItem("123"); to DropdownListe2.addItem("Value A"); ...

I hope it's helpful for you,

kind regards,

Mandy

Avatar

Former Community Member

Hello Mandy,

THanx for your reply. I will try this solution asap and will let you know if it worked!

Daniel

Avatar

Former Community Member

Hello Mandy,

I encountered the first problem. Probably a language thing. I work in a dutch version...

A made a testform to try the script. It gave the following message when i wanted to check the preview:

Script failed, Function: switch on line 1 is unkown....

Question: do i add the script by the scripteditor..?

Thanx again

Avatar

Level 5

Hi,

the language cant' be the mistake. I work with two different versions (german and english).

You have to do this script in the change or exit-event of the first dropdown.

You will find the script editor:

"Fenster"/"Window" | "Skripteditor"/"Scripteditor"

Kind regards Mandy

PS: You will find an example. https://workspaces.acrobat.com/?d=XQKpkDs0XsADxvKLMwzTUg

Avatar

Former Community Member

I really feel like a real newby (which is kind of true)...

The first problem is solved. Wrong language (java/ formcalc).

I copied your script. I do get the values in dropbox 1, but no results in dropbox 2...I expected to see 456, 678 in box 2 after selecting 123 in box 1. Is that correct?

Example does not work. Probably outdated version of adobe on my PC. Will try to fix that later...

Thanx

Avatar

Correct answer by
Level 5

I make the pdf compatible for ES 8. Now it should be work. https://workspaces.acrobat.com/?d=qBsk3hERFH2RcSn5vQ5rBg

When the script doesn't work you have to check

script language - javascript

objectname - is your objectname the same as (when your dd called dd_choice2 or dropbox_2, then you have to change the script)

case "123":

        dropbox_2.clearItems();

        dropbox_2.addItem("Please select a value");

        dropbox_2.addItem("456");

        dropbox_2.addItem("789");

        dropbox_2.selectedIndex = 0;

        break;

The behaviour is correct when you copy them.

You select "123"

     2. DD "456" and "678"

You select "456"

     2. DD "123" and "678"

You select "678"

     2. DD "456" and "678"

Please give feedback tomorrow if it's work.

Kind regards Mandy

Avatar

Former Community Member

Hello Mandy.

IT WORKS!!! Thank you very much.

I still have some testing/ editing to do but you have helped me a lot.!

Thanx again!

Daniel