Expand my Community achievements bar.

SOLVED

Linking 2 drop down fields and have certain field appear

Avatar

Level 4

I've been reading about linking two dropdown lists where you select one thing in the first dropbox and then it adjusts the options in the second dropdown box.  I like those and may use those in the future.  I have a somewhat related question.

Can I have two drop down lists that both selections control what fields display below?  For examples list 1 has A, B, and C, and List 2 has Red, Orange, and Yellow.  I will pick different combinations of the two and have different things display.  A and Red has fields 1, 2, and 3 show.  B and Yellow has 1 and 3 display, and so on.

Is this even possible or do I need to create the different combinations all in one field and script the different responses which I believe I know how to do?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

The trouble is that you are hiding the subform, BUT then trying to set the presence of individual checkboxes within the subform to visible. This will not work, because the subform itself is set to hidden.

Look at the checkboxes and see if you can group them into sets that are always either hidden or visible. Then script against the subforms and NOT the checkboxes. If you cannot group the checkboxes then you are just going to have to reference them individually.

The textfield was just a typo.

Niall

View solution in original post

6 Replies

Avatar

Level 10

Hi,

There are a couple of examples here, which may help: http://assure.ly/jcTahK, http://assure.ly/fYCuQ2 and http://assure.ly/jtTkdO.

You would need to set up an if/else statement that would be the same for each of the dropdown exit events:

// First hide everything

Textifled1.presence = "hidden";

Textifled2.presence = "hidden";

Textifled3.presence = "hidden";

// Then test each of the dropdowns

if (dropdown1.rawValue == "A" && dropdown2.rawValue == "1") {

     Textifled1.presence = "visible";

}

else if (dropdown1.rawValue == "A" && dropdown2.rawValue == "2") {

     Textifled2.presence = "visible";

}

else if (dropdown1.rawValue == "B" && dropdown2.rawValue == "1") {

     Textifled3.presence = "visible";

}

Hope that helps,

Niall

Avatar

Level 4

This is making sense, but I have a couple of follow up questions...

1. // First hide everything
Textifled1.presence = "hidden";
Textifled2.presence = "hidden";
Textifled3.presence = "hidden";

Does that go on the exit event as well?

2.  Can I wrap all my fields that may possibly display in a subform and hide that at the start and then name the fields individually in the if/else statements?  I know I need to id the subform in the script?

Thanks!

Avatar

Level 10

Hi,

Yes, if there are lots of objects that can be grouped in a subform, then that is going to make the script much easier. Yes, you would then need to provide a relative reference from the object with the script to the subforms.

The reason I am recommending that you first hide all of the objects whose presense is going to be changing (in this case subforms) is that it makes the script in the if/else statement much easier/cleaner, as you are only changing back the presence of selected subforms back to visible.

The whole script block would go in the exit event.

Good luck,

Niall

Avatar

Level 4

I feel like I'm getting somewhere, but now I'm stuck again.  I put in a little bit of the choices that I wanted and here's what happens.  I go to the form and the whole list is there, which is fine.  I make my first dropdown selection and all my choices disappear (also fine).  I make my second drop down selection and nothing appears (not fine).  I'm not sure quite what's going wrong.  I've included a link to my sample file.  I noticed that for your text fields you said Textifled each time.  Does the "if led" mean something?

https://acrobat.com/#d=4FTLChFAT7RWVTcuOTtSvQ

Thanks!

Avatar

Correct answer by
Level 10

Hi,

The trouble is that you are hiding the subform, BUT then trying to set the presence of individual checkboxes within the subform to visible. This will not work, because the subform itself is set to hidden.

Look at the checkboxes and see if you can group them into sets that are always either hidden or visible. Then script against the subforms and NOT the checkboxes. If you cannot group the checkboxes then you are just going to have to reference them individually.

The textfield was just a typo.

Niall

Avatar

Level 4

Thanks for all your help!  I think I got it all working now!