Dependent Dropdowns Dependent Cases
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
