Copy link to clipboard
Copied
Hi. I'm trying to dynamically change the choices in a drop-down field based on what option was selected in the previous drop-down field. I'm using the following formula as my template:
if (this.getField("Drop-Down 1").value == "A"){
this.getField("Drop-Down 2").setItems([" ", "A1", "A2", "A3"])
}
else if (this.getField("Drop-Down 1").value == "B"){
this.getField("Drop-Down 2").setItems([" ", "B1", "B2", "B2"])
}
When using this template, the second drop-down is correctly adjusting what options it shows. However, after selecting an option and clicking away from the field, the field keeps reverting back to blank instead of the option I selected.
Any help figuring out what I'm doing wrong would be greatly appreciated.
Where do you use code?
Put it in "Drop-Down 1" as validation script and change this.getField("Drop-Down 1").value to event.value.
Copy link to clipboard
Copied
Where do you use code?
Put it in "Drop-Down 1" as validation script and change this.getField("Drop-Down 1").value to event.value.
Copy link to clipboard
Copied
Hi Nesa,
The script is currently in the Custom Calculation for for Drop-Down 2.
I'm pretty new to this, so I apologize for not having a strong grasp of your suggestions. You're saying I should remove this script from where I have it in Drop-Down 2 and move it to a Validation script in Drop-Down 1? And changing to event.value, would it look like this:
if (event.value == "A"){
this.getField("Drop-Down 2").setItems([" ", "A1", "A2", "A3"])
}
else if (event.value == "B"){
this.getField("Drop-Down 2").setItems([" ", "B1", "B2", "B2"])
}
Copy link to clipboard
Copied
Yes, try that.
Copy link to clipboard
Copied
Hi Nesa,
That did the trick! Thank you for your help!
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
This question has been asked quite a bit. In fact, you'll find an article on the topic here:
https://acrobatusers.com/tutorials/js_list_combo_livecycle/
and Here:
https://acrobatusers.com/tutorials/change_another_field/