Expand my Community achievements bar.

How to make two Drop-Down list work together

Avatar

Level 2

I need to have two drop-down list work together, but I have NO idea how to make them do it.

Here's what I'm trying to accomplish. Whatever the user selects from drop down list 1, it will automatically have drop down list fill with specific options.

Example: User selects COMMISSIONER'S OFFICES from drop down llist #1 and then in drop down list #2, the options MASTER, OFFICE OF THE CHAIRMAN, OFFICE OF COMMISSIONER, and OFFICE OF THE OS appear.

Division (drop down list 1)
Department (drop down list 2)
COMMISSIONER'S OFFICESMASTER

OFFICE OF THE CHAIRMAN

OFFICE OF COMMISSIONER

OFFICE OF THE OS
OFFICE OF PUBLIC AFFAIRSMASTER

ASSISTANT DIRECTOR

DEPUTY DIRECTOR

OCIO
OED - RECORDS & FILINGS061201 [RECORDS & INFORMATION MANAGEMENT]

061202 [DOCUMENT PROCESSING]
4 Replies

Avatar

Level 5

Hi

You can write a script on the event Change of the 1st dropdown field.

It would be something like this:

If (field.rawValue == "COMMISSIONER'S OFFICES")

{

     field2.clearItems();

     field2.addItem("MASTER");

     field2.addItem("OFFICE OF THE CHAIRMAN");

     field2.addItem("OFFICE OF COMMISSIONER");

     field2.addItem("OFFICE OF THE OS");

}

Hope it helps.

Diego

Avatar

Level 2

Hi. I am following this train of thought.

I have 2 drop downs. I want the second series of values to be dependant on the first choice.

Here is what I have so far based on what you posted.

The first drop down has 2 options

PRD-ER and 451P

Here is what I have so far and I am having difficulty tying this up.

I need a little help please.

If (IMN.rawValue == "PRD-ER")

{

     BGR.clearItems();

     BGR.addItem("1 μR/hr-PRD-ER");

     BGR.addItem("2 μR/hr-PRD-ER");

     BGR.addItem("3 μR/hr-PRD-ER");

     BGR.addItem("4 μR/hr-PRD-ER");

     BGR.addItem("5 μR/hr-PRD-ER or 451P");


}

I guess I need some kind of if statement in here to clarify the second choice of 451P

If (IMN.rawValue == "451P")

{

     BGR.clearItems();

     BGR.addItem("5 μR/hr-PRD-ER or 451P");

     BGR.addItem("6 μR/hr-451P");

     BGR.addItem("7 μR/hr-451P");

     BGR.addItem("8 μR/hr-451P");

     BGR.addItem("9 μR/hr-451P");

     BGR.addItem("10 μR/hr-451P");

     BGR.addItem("11 μR/hr-451P");

     BGR.addItem("12 μR/hr-451P");

     BGR.addItem("13 μR/hr-451P");

     BGR.addItem("14 μR/hr-451P");

     BGR.addItem("15 μR/hr-451P");


}

I guess I want to keep the 2nd drop down clear if the first choice is null..right?

Any help is appreciated.

Thank you.

Aky

Avatar

Level 5

Hi

I applied your code in a new form and worked fine. Only note that your "if" statement must be in lower case.

You can download the PDF sample I made here: http://diegosi.wordpress.com/?attachment_id=283

Hope it helped.

Cheers

Diego

Avatar

Level 2

Thank you very much.

This is the code I ended up with:

I cobbled it together from the forums and it seems to work well.

// Since entries are added one at a time it is necessary to clear out the list
   BGR.clearItems();
  // The ComboBox value is not dependant on the list selection so we
  // have to also clear this
   BGR.rawValue = null;

var myObj={"PRD-ER":"1 μR/hr-PRD-ER,2 μR/hr-PRD-ER,3 μR/hr-PRD-ER,4 μR/hr-PRD-ER,5 μR/hr-PRD-ER,OUT OF RANGE-DESCRIBE/COMMENT",
                    "451P":"5 μR/hr-451P,6 μR/hr-451P,7 μR/hr-451P,8 μR/hr-451P,9 μR/hr-451P,10 μR/hr-451P,11 μR/hr-451P,12 μR/hr-451P,13 μR/hr-451P,14 μR/hr-451P,15 μR/hr-451P,OUT OF RANGE-DESCRIBE/COMMENT"};
BGR.setItems(myObj[this.boundItem(xfa.event.newText)]);

Making a change in the first dropdown clears out the second drop down.

Now I need to figure out how to make 4 other fields invisible until the "OUT OF RANGE" is selected.

Thank you very much.