Skip to main content
New Participant
January 31, 2025
Answered

Dependent Dropdowns Dependent Cases

  • January 31, 2025
  • 3 replies
  • 1251 views

To Whom it May Concern,

 

I am trying to get some assistance with both, mulitple dropdowns list working together with mulitple cases conditions within those same dropdowns list , but I am unable to find the correct solution.

 

I have three dropdowns fields. 

Dropdown 1,  Dropdown 2, and Dropdown 3.

 

Dropdown 1 list is independent of any other dropdown fields, or text boxes.  Dropdown 1 list contain two digit values, ("01", "02", "03", "04",  etc..)

 

Dropdown 2 list is supposed to be dependent on the result of what was picked from Dropdown 1 list. 

Dropdown 2 list also contains a list of two digit values, ("01", "02", "03", "04",  etc..) (*Please note that the individual items in Dropdown 1 and Dropdown 2 look the same, but in reality represent different things).

 

Dropdown 3 list is supposed to be dependent on the result that was picked from Dropdown 1 list AND the results of Dropdown 2 pick.

 

Dropdown 3, contains a list of items, ("A", "B", "C", etc..)

 

All dropdown three fields have the "Commit selected value immediately" option selected.

 

In addition to assigning the list from Dropdown 1 to Dropdown 2, and producing a list based on the pick of DropDown 1 AND Dropdown 2 to produce Dropdown 3 list.  I am trying to get this Switch Case function to work properly.  

 

Some of my effort toward achieving my goal has resulted in postive results, if I am only using what I call one case conditon.  However, if I use two or more case condtions trying to employ this "Fall Through technique" that I read about, I am getting hit or miss results.

 

Here is my code that I place in Dropdown 1 "Custom Keystroke Script" editor:

 

if (!event.willCommit){
var a = this.getField("Dropdown2");
var b = this.getField("Dropdown3");
a.clearItems();
b.clearItems();


switch (event.change){

case "01":
a.setItems(["Select ","01", "02", "03", "04", "11"]);
break;

case "02":
a.setItems(["Select ","01", "02", "03", "06",]);
break;

}

}

 

 

The code that I put Dropdown 2 "Custom Keystroke Script" editor looks like this:

 

if (!event.willCommit){
var b = this.getField("dropdown1")
var c = this.getField("dropdown2")
var d = this.getField("dropdown3");

c.clearItems();
d.clearItems();

 

switch (event.change){

case "01":
case "01":
d.setItems(["Preparers1"])
break;

 

case "01":
case "02":
d.setItems(["Preparers2"])
break;

 

case "01":
case "03":
d.setItems(["Preparers3"])
break;

 

case "01":
case "04":
d.setItems(["Preparers4"])
break;

 

case "01":
case "11":
d.setItems(["Preparers5"])
break;

 

case "02":
case "01":
d.setItems(["Preparers6"]);
break;

 

case "02":
case "02":
d.setItems(["Preparers7" ]);

break;

 

case "02":
case "03":
d.setItems(["Preparers8",]);

break;

 

case "02":
case "06":
d.setItems(["Preparers9"]);
break;

}

}

 

 

The results after picking a item from dropdown 1 and dropdown 2  list don't give me what I should be seeing in dropdown 3 list.  Either I am getting nothing showing up at all in Dropdown 3, or I get the wrong output.

 

For example, I might pick "02" from Dropdown 1, and "04" from Dropdown 2, and I may get nothing in dropdown 3, but sometimes if change Dropdown2 back to something else, I might get something, but its typically wrong.  It almost like Javascript is picking its time to run the code, and when it does choices to randomaly assigned values.

 

I was told to use switch case option as oppose to using an large if statements.  But neither approaches are working for me.

 

I also consider trying to combined the results from Dropdown 1 and Dropdown 2 into a single output to run the cases on one condition case as opposed to two cases conditions.  But I don't know how to combined outputs from both dropdowns.  I know I am close to a solution, but I can't find that last little bit to get me over the hump.

 

Any solutions in any direction would be appreciation. Thank you

    Correct answer try67

    The logic of your cases is flawed. If you have one case for "01" you can't have another for it later on, as it would never be reached. Can you explain in words what you're to achieve, exactly?

    3 replies

    try67
    try67Correct answer
    Brainiac
    January 31, 2025

    The logic of your cases is flawed. If you have one case for "01" you can't have another for it later on, as it would never be reached. Can you explain in words what you're to achieve, exactly?

    New Participant
    January 31, 2025

    Try67,

     

    Thank you reponse, however, I am not sure I understand fully your explaination.

     

    So, if I have three dropdown fields.  

    in which Dropdown2 list depends on Dropdown1's pick, and Dropdown3 list depends on Dropdown1 AND Dropdown2 picks.  AND Dropdown1 list of choices share similar naming convention to Dropdown2 list even though they represent different entities.

     

    Are you saying that I can't have any of Dropdown2 choices match any of the choices of Dropdown1 if I wish to use a switch case methodology? 

     

    For example:

    if 

    Dropdown1 (D1) has the following list:

    "01"

    "02"

    "03"

     

    Dropdown2 (D2) has the following list

    "01"

    "02"

    "03"

     

    Dropdown3 (D3) has the following list:

    "A"

    "B"

    "C"

     

    and I go to pick from any of the following combination:

    Dropdown1, "01", and from Dropdown2, "01", and Dropdown3, "A" - (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "01", and from Dropdown2, "01", and Dropdown3, "B"- (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "01", and from Dropdown2, "01", and Dropdown3, "C"- (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "01", and from Dropdown2, "02", and Dropdown3, "A" 

    Dropdown1, "01", and from Dropdown2, "02", and Dropdown3, "B"

    Dropdown1, "01", and from Dropdown2, "02", and Dropdown3, "C"

    Dropdown1, "01", and from Dropdown2, "03", and Dropdown3, "A"

    Dropdown1, "01", and from Dropdown2, "03", and Dropdown3, "B"

    Dropdown1, "01", and from Dropdown2, "03", and Dropdown3, "C"

     

    Dropdown1, "02", and from Dropdown2, "01", and Dropdown3, "A"

    Dropdown1, "02", and from Dropdown2, "01", and Dropdown3, "B"

    Dropdown1, "02", and from Dropdown2, "01", and Dropdown3, "C"

    Dropdown1, "02", and from Dropdown2, "02", and Dropdown3, "A"- (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "02", and from Dropdown2, "02", and Dropdown3, "B"- (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "02", and from Dropdown2, "02", and Dropdown3, "C"- (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "02", and from Dropdown2, "03", and Dropdown3, "A"

    Dropdown1, "02", and from Dropdown2, "03", and Dropdown3, "B"

    Dropdown1, "02", and from Dropdown2, "03", and Dropdown3, "C"

     

    Dropdown1, "03", and from Dropdown2, "01", and Dropdown3, "A"

    Dropdown1, "03", and from Dropdown2, "01", and Dropdown3, "B"

    Dropdown1, "03", and from Dropdown2, "01", and Dropdown3, "C"

    Dropdown1, "03", and from Dropdown2, "02", and Dropdown3, "A"

    Dropdown1, "03", and from Dropdown2, "02", and Dropdown3, "B"

    Dropdown1, "03", and from Dropdown2, "02", and Dropdown3, "C"

    Dropdown1, "03", and from Dropdown2, "03", and Dropdown3, "A"- (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "03", and from Dropdown2, "03", and Dropdown3, "B"- (Are you saying this is invalid, D1 and D2 matches?)

    Dropdown1, "03", and from Dropdown2, "03", and Dropdown3, "C"- (Are you saying this is invalid, D1 and D2 matches?)

     

    Essentially, using this example, I need to be able to pick from Dropdown1 choice using this two digit veribages, which just so happens to match the veribage choices of dropdown 2 list. (meaning sometimes they'll match and sometime that won't) and allow me to get the 27 different cominbation of results. But also remembering that Dropdown2 list depends on Dropdown1 pick  AND Dropdown3 list depends on both Dropdown1 And Dropdown2 pick.

     

    Does this additional information help with what I am trying to do?

     

    Thank you

     

    try67
    Brainiac
    January 31, 2025

    Use something like this, then:

     

    var v1 = this.getField("Dropdown1").valueAsString;
    var v2 = this.getField("Dropdown2").valueAsString;
    var v3 = this.getField("Dropdown3").valueAsString;

    if (v1=="01" && v2=="01" && v3=="A") event.value = "Are you saying this is invalid, D1 and D2 matches?";
    else if (v1=="01" && v2=="01" && v3=="B") event.value = "Are you saying this is invalid, D1 and D2 matches?";

    // etc.

    New Participant
    January 31, 2025

    Yes.

    kglad
    Brainiac
    January 31, 2025

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



    <"moved from using the community">
    kglad
    Brainiac
    January 31, 2025

    is this an acrobat question?