Copy link to clipboard
Copied
I was using the switch script in a custom calculation script in a dropdown to populate a 2nd dropdown (which works correctly), but I can't actually make a selection in the 2nd dropdown list. The list is made and I can click on it to see the populated options, but clicking off the dropdown list after selecting an option besides the first causes it to revert back to the default choice. I assume it has something to do with the list being re-populated after making my choice, but I have no idea on how to stop it.
Copy link to clipboard
Copied
Don't use a calculation script for this.
Copy link to clipboard
Copied
What do you suggest I use instead?
Copy link to clipboard
Copied
The first dropdown calculation script gets triggered whenever any field value changes, so when you make a selection in the second dropdown, it gets triggered and resets the second dropdown. Without knowing more about how the form is intended to work, it's hard to give a specific recommendation. Using a custom validation or keystroke script instead in the first dropdown would probably be better. It would probably help if you posted the calculation script you're using now.
Copy link to clipboard
Copied
Here's an example:
switch (event.value) {
case "1":
this.getField("Sub1").setItems([""]);
break;
case "2":
this.getField("Sub1").setItems(["","1","2","3"]);
break;
case "3":
this.getField("Sub1").setItems([""]);
break;
case "4":
this.getField("Sub1").setItems([""]);
break;
case "5":
this.getField("Sub1").setItems(["","1","2","3"]);
break;
}
The Sub1 dropdown will populate a blank space, 1, 2, and 3 when I select 2 on the first dropdown, but like I said, It'll go back to the blank spot when I click off. How do you suggest I change my script so that it works in custom validation or a keystroke script?
Copy link to clipboard
Copied
Just move it as-is to be a custom validation script.