Copy link to clipboard
Copied
I'm working on a form and have a question concerning a few of the fields.
I have a drop-down field that will have 4 options - Urgent Intervention, Intervention, On Watch, and At/Above Benchmark
I'm looking for a script that would change the field color based on which option was selected. I need the field to be red if Urgent Intervention is selected, yellow if Intervention is selected, blue for On Watch, and green for At/Above Benchmark.
I don't know much about scripts, and I've tried to find options, but I can't find anything that works.
Thanks in advance.
Copy link to clipboard
Copied
You can control either the text color, the background color, or the border color. Can you clarify which you want?
Copy link to clipboard
Copied
I am referring to background/fill color. Looking through different discussions, I've managed to piece together this:
var vcolor = event.value;
if (vcolor == "Urgent Intervention") {
this.getField('Dropdown5').fillColor = color.red;
}
else if (vcolor == "Intervention") {
this.getField('Dropdown5').fillColor = color.yellow;
}
else if (vcolor == "On Watch") {
this.getField('Dropdown5').fillColor = color.blue;
}
else if (vcolor == "At/Above Benchmark") {
this.getField('Dropdown5').fillColor = color.green;
}
else if (vcolor == "n/a") {
this.getField('Dropdown5').fillColor = color.white;
}
It appears to work how I intended it to, but I'm not sure if that's the best way to go about it. Without having any background on scripts, I just got lucky.
Copy link to clipboard
Copied
Is that script a custom validation script of the Dropdown5 field?
Copy link to clipboard
Copied
Yes, Dropdown5 is the name of the field that I'm experimenting on, and that's a script I pieced together for Validation.
Copy link to clipboard
Copied
In that case, change the lines of code like this:
this.getField('Dropdown5').fillColor = color.red;
to this:
event.target.fillColor = color.red;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now