Copy link to clipboard
Copied
Hello,
I am new to javascript. I followed a tutorial to be able to autopopulate a dropdown based on another, but I don't know how to make it work based on the selections of two dropdowns.
I have 7 options in the first column (discipline), and 5 levels in the second column (level). Depending on what is selected in those two, I need to auto populate different options in the third row (power).
¿Could someone help me with that?
Copy link to clipboard
Copied
You can use something like this as custom calculation script of 3rd dropdown, change choices with actual values:
if (event.source && (event.source.name=="row1.discipline" || event.source.name=="row1.level")) {
var d1 = this.getField("row1.discipline").valueAsString;
var d2 = this.getField("row1.level").valueAsString;
if(d1 == "Choice1" && d2 == "Choice2")
event.target.setItems(["Choice1", "Choice2", "Choice3"]);
else if(d1 == "Choice2" && d2 == "Choice2")
event.target.setItems(["Choice4", "Choice5", "Choice6"]);
else
event.target.clearItems();}
Copy link to clipboard
Copied
You can use something like this as custom calculation script of 3rd dropdown, change choices with actual values:
if (event.source && (event.source.name=="row1.discipline" || event.source.name=="row1.level")) {
var d1 = this.getField("row1.discipline").valueAsString;
var d2 = this.getField("row1.level").valueAsString;
if(d1 == "Choice1" && d2 == "Choice2")
event.target.setItems(["Choice1", "Choice2", "Choice3"]);
else if(d1 == "Choice2" && d2 == "Choice2")
event.target.setItems(["Choice4", "Choice5", "Choice6"]);
else
event.target.clearItems();}