Copy link to clipboard
Copied
Hi all,
I am trying to get fields to auto-populate based on selections from multiple drop down boxes. I currently have used things to auto-populate based off of a single drop down selection using the below script:
However I want to set it up so that certain options come up if selections from multiple fields are true. Example would be:
Drop-Down 1; selection 1 and drop-down 2; selection 1 gives you response 1
Drop-Down 1; selection 2 and drop-down 2; selection 1 gives you response 2
Drop-Down 1; selection 1 and drop-down 2; selection 2 gives you response 3
Drop-Down 1; selection 2 and drop-down 2; selection 2 gives you response 4
Is this possible?
Thanks.
So, this looks like you are using a calculation script on the target field? All you need to do is make some simple modifications the script.
...var f = this.getField("Dropdown1");
var g = this.getField("Dropdown2");
if ((f.valueAsString=="Option 1") && (g.valueAsString == "Choice1")) event.value = "Text 1";
else if ((f.valueAsString=="Option 2") && (g.valueAsString == "Choice2")) event.value = "Text 2";
else if ((f.valueAsString=="Option 3") && (g.valueAsString == "Choice3")) event.value = "Text 3
Copy link to clipboard
Copied
So, this looks like you are using a calculation script on the target field? All you need to do is make some simple modifications the script.
var f = this.getField("Dropdown1");
var g = this.getField("Dropdown2");
if ((f.valueAsString=="Option 1") && (g.valueAsString == "Choice1")) event.value = "Text 1";
else if ((f.valueAsString=="Option 2") && (g.valueAsString == "Choice2")) event.value = "Text 2";
else if ((f.valueAsString=="Option 3") && (g.valueAsString == "Choice3")) event.value = "Text 3";
else event.value = "Default text";
Copy link to clipboard
Copied
Awesome, thanks for the quick response. One other question, is it possible to maybe only program some of the options, but have it display a default text if none of the rules apply? Meaning if I do the option 1, choice 1, I get text 1, so on and so forth for the specific messages I need for certain pairings, but for pairings that don't matter it can just go to a default text?
Copy link to clipboard
Copied
Please disregard. LOL