Text field color fill from multiple dropdowns
Copy link to clipboard
Copied
I have an adobe form with 4 dropdown list. All 4 dropdowns have the same information. I am trying to get a text box to change the fill color based on the selection from the dropdown list regaurdless us whic one I use. I have managed to get this to work for the one of them but can't figure out the code for all 4.
Copy link to clipboard
Copied
What script does you use?
Copy link to clipboard
Copied
I used the below in in Custom calculation script.
var indicator = this.getField("STP-1").value; {
if (indicator=="Absent")
event.target.fillColor = color.green;
else if (indicator=="Tardy")
event.target.fillColor = color.green;
else if (indicator=="Exited")
event.target.fillColor = color.red;
else if (indicator=="Recycle")
event.target.fillColor = color.yellow;
else
event.target.fillColor = color.transparent;
event.target.fontColor = color.transparent;}
Copy link to clipboard
Copied
What if one field has Tardy selected and another Recycled? Which color should be used then?
Copy link to clipboard
Copied
Yellow regardless of the tardy, recycle would be the color through out the course.
Copy link to clipboard
Copied
You need to explain the logic behind it, then. Which colors have precedence over which ones?
Copy link to clipboard
Copied
It is an attendance sheet, if the partictpant is present for the fist half of the day and not there for the aftrenoon and I select "absent" for the afternoon then I want partcipant field green to match the absent from thr dropdown list. The same if they recycle or exited.
Copy link to clipboard
Copied
I'm sorry, but you didn't really answer my question. In your examples all the options are the same. The question is what should happen if they are not the same.
Copy link to clipboard
Copied
If the form is completed correctly, there should not be mulitle selection. However Exited "red" should override any other choice. Recycle "yellow" overrides absent or tardy "green". I can eleminate Tardy if needed.
Copy link to clipboard
Copied
OK, now it's more clear. You can use this code as the custom calculation script of the Participant Name fields:
var rowNumber = event.target.name.replace("PARTICIPANT NAMERow", "");
var fields = ["STP-"+rowNumber, "LOP-"+rowNumber, "LIP-"+rowNumber, "ETP-"+rowNumber];
var bAbsent = false;
var bTardy = false;
var bExited = false;
var bRecycle = false;
for (var i in fields) {
var f = this.getField(fields[i]);
var v = f.valueAsString;
if (v=="bAbsent") bAbsent = true;
if (v=="Tardy") bTardy = true;
if (v=="Exited") bExited = true;
if (v=="Recycle") bRecycle = true;
}
if (bExited) event.target.fillColor = color.red;
else if (bRecycle) event.target.fillColor = color.yellow;
else if (bAbsent || bTardy) event.target.fillColor = color.green;
else event.target.fillColor = color.transparent;

