Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Populating a drop down box based on another drop down box selection

donn44157260
Level 5
Level 5

Good day all;

On a form I am designing I have 2 drop down menus labeled, directorate and division.

What I would like to do is when the user selects a directorate, the division drop down is only populated with a list of divisions that belong to the selected directorate.

I am sure I have seen this question asked before, but, I am at a loss to find it…..

Thanks All

Chomp

1 Accepted Solution
Jono_Moore
Correct answer by
Level 10
Level 10

Anybody else lost the ability to get at the advanced formatting (setting font family, etc.)? Can't seem to find where it's gone...

View solution in original post

0 Replies
donn44157260
Level 5
Level 5

Thanks Srini.

Before I saw your post I found the following. In your option which one would be better to use? I am looking at 5 directorates and each directorate having an max of 7 divisions

if(boxA.rawValue == "month")

{

  1. boxB.clearItems();
  2. boxB.addItem("JAN");
  3. boxB.addItem("FEB");
  4. boxB.addItem("MAR");

}

if(boxA.rawValue == "year")

{

  1. boxB.clearItems();
  2. boxB.addItem("2012");
  3. boxB.addItem("2011");
  4. boxB.addItem("2010");

}

Jono_Moore
Level 10
Level 10

I find it easier to do with a switch() statement and hand code it but if you have a lot of data doing some sort of loop through an array might be easier.

Below is just a small snip of quite a long list I have in one form. Using xfa.event.newText to get immediate response from the dropdown.

//on the Change event

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

Desc.clearItems(); //Desc is the target dropdown

Desc.rawValue = "";

//above line needed to clear the displayed value in the next dropdown, clearItems() just clears the list.

 

switch (selection)

{

  case "AE":

       Desc.addItem("DF");

       Desc.addItem("FR");

       Desc.addItem("MS");

       Desc.addItem("PC");

  break;

  case "AN":

       Desc.addItem("BI");

       Desc.addItem("FI");

       Desc.addItem("GE");

       Desc.addItem("OT");

       Desc.addItem("ZO");

  break;

}

Jono_Moore
Correct answer by
Level 10
Level 10

Anybody else lost the ability to get at the advanced formatting (setting font family, etc.)? Can't seem to find where it's gone...

View solution in original post

embroideryallso
Level 1
Level 1

I have copied and pasted this exactly as it is here, I have named my target field DESC and I can't get it to work. I have pasted it into a change event on the first drop down box and then I tried it on the target drop down box. Can you please tell me what I am missing? I have read heaps of posts and they all say to do this differently, I am very confused.

Jono_Moore
Level 10
Level 10

The code goes on the first drop down. You have to make sure the values match, in my code the "AE" and "AN" are possible selections in the dropdown, so make sure you are using matching your own dropdown selections. If you've assigned values to the dropdown selections then you would use those instead.

embroideryallso
Level 1
Level 1

Thanks Jono, I did eventually get that to work using your code from a different post. not sure what the difference was now because I have read so many different posts and I am now very confused.