Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Dropdown display changes based on user selection in previous dropdown list

Avatar

Level 1

Hi,

I am really having trouble with this and spent a lot of time researching several blogs, tutorials, youtubes, etc. I just cannot get what I've found to work for me.  I am creating a simple form in LiveCycle Designer 8.0.  I have a table of 14 rows and four columns (row one is the header).  Each cell in the first 3 columns contain a dropdown filling the thirteen rows.  The last row is a user entered numerical field.  My query is related to the second column's drop downlist (months1) containing two items (24, 38) and the third column drop downlist (hours1) containing 5 items (4,000, 6,000, 8,000, 10,000, and 12,000).  In addition, there is a default item in each drop down set at <select>.

I would like to have the instructions and script needed that will display the correct list of choices to the users in the "hours1" drop down list based on what was selected in the months1 dropdown.

For example;

if the user selects "24" in the months1 dropdown, then the hours1 dropdown should display "4,000, 6,000, and 8,000" only.
if the user selects "36" in the months1 dropdown, then the hours1 dropdown should display "6,000, 8,000, 10,000 and 12,000" only.

This type of coding would be great to replicate in other forms I have been tasked to do.  Thanks!

7 Replies

Avatar

Level 10

You can populate dropdown lists using addItem(). The script goes on the Change event of the first dropdown list.

var selection = this.boundItem(xfa.event.newText);

hours1.clearItems();

hours1.rawValue = "";

 

switch (selection){

     case "24":

          hours1.addItem("4,000");

          hours1.addItem("6,000");

          hours1.addItem("8,000");

     break;

     case "36":

          hours1.addItem("6,000");

          hours1.addItem("8,000");

          hours1.addItem("10,000");

          hours1.addItem("12,000");

     break;

}

Avatar

Former Community Member

Please, I would like to do the same thing but on a table whose rows are incremented with an "add" button or remove with a "delete" button. I tried but it only works with the first row, second row after a click on the "add" button it gives me the list without any differentiation.
help me

Avatar

Level 1

This is helping me out. The only thing I am having trouble with is running the script from a function set up as a variable. I have a variable called "Members" set up with the following function:

function TeamMembers()

{

          TimeSheetSF.EmployeeInfoSF.TeamMemDrop.rawValue = "";

          TimeSheetSF.EmployeeInfoSF.TeamMemDrop.clearItems();

          var myTeam = this.boundItem(xfa.event.newText);

          switch (myTeam)

          {

                    case "Team 0":

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Cheryl");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Neil");

                              break;

                    case "Team 1":

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Pat");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Carl");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Conn");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Gayle");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Gene");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("John");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Mich");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Malind");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Alan");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Maln");

                              break;

                    case "Team 2":

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("David");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Cris");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Chad");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Linda");

                              TimeSheetSF.EmployeeInfoSF.TeamsDrop.addItem("Steph");

                              break;

}

}

When I add the following to the change event of the first field and run it nothing happens. The drop down in the TeamsDrop drop-down field does nothing.

Members.TeamMembers();

If I add all of the code to the change event without it being wrapped in a function it works. I can't figure what I am doing wrong.

I might add that I am creating the first drop down using a function in a variable and it works just fine.

Avatar

Level 10

I wouldn't bother making it into a script object function unless you are calling it from multiple places, there's not much point. Just put it on the change event of the field itself.

Same with the first dropdown - unless the data is changing you don't need scripting, just populate the data for the dropdown on the Object palette.

Avatar

Level 1

I will take your advice. I think at the time I originaly created these was to learn some more scripting skills. I am curious why one works while the other doesn't.

Thanks for the help.

Avatar

Level 2

Thank you for the post. I am using this script and it works perfectly, but when I am previewing the dropdowns after making a selection I cannot go back and change my selection in the first dropdown. My example is a Human resources form which has Part Time and Seasonal as the picks, the second dropdown displays the employee titles associated with the first dropdown pick. If the user mistakenly chooses the wrong item in the first dropdown I want them to be able to go back and make a different selection. Thank you for your time.

Avatar

Level 2

For help with the reply I posted please see the reply to the post in the following link, it gives two options. Thanks

http://forums.adobe.com/message/5405220#5405220