Skip to main content
Participating Frequently
December 20, 2023
Answered

Text color fill based on multiple dropdown lists

  • December 20, 2023
  • 2 replies
  • 965 views

I created a digital attendance roster to track attendance. I have 4 dropdown list with 5 selection in each dropdown and this list is the same for all dropdowns. I would like the text field to change fill color based on the selection from the dropdown list. I have provided a picture of the roster and notated what i'm trying to create.

This topic has been closed for replies.
Correct answer Nesa Nurani

Remove all scripts from "PARTICIPANT NAMERow", "INSTITUTIONRow" and "EMPLOYEE IDRow" fields and put this script in one of the fields as custom calculation script  (only one field is enough, it will work on all 5 fields):

for(var i=1; i<=5; i++){
 var PN = this.getField("PARTICIPANT NAMERow"+i);
 var IN = this.getField("INSTITUTIONRow"+i);
 var EM = this.getField("EMPLOYEE IDRow"+i);

 var stp = this.getField("STP-"+i).valueAsString;
 var lop = this.getField("LOP-"+i).valueAsString;
 var lip = this.getField("LIP-"+i).valueAsString;
 var etp = this.getField("ETP-"+i).valueAsString;

 if(stp == "Exited" || lop == "Exited"  || lip == "Exited" || etp == "Exited"){
  PN.fillColor = color.red;
  IN.fillColor = color.red;
  EM.fillColor = color.red;}
 else if(stp == "Tardy" || stp == "Absent" || lop == "Tardy" || lop == "Absent" || lip == "Tardy" || lip == "Absent" || etp == "Tardy" || etp == "Absent"){
  PN.fillColor = color.green;
  IN.fillColor = color.green;
  EM.fillColor = color.green;}
 else if(stp == "Recycle" || lop == "Recycle"  || lip == "Recycle" || etp == "Recycle"){
  PN.fillColor = color.yellow;
  IN.fillColor = color.yellow;
  EM.fillColor = color.yellow;}
 else{
   PN.fillColor = color.transparent;
   IN.fillColor = color.transparent;
   EM.fillColor = color.transparent;}}

 

2 replies

Bernd Alheit
Community Expert
Community Expert
December 20, 2023

Duplicate posting 

Nesa Nurani
Community Expert
Community Expert
December 20, 2023

What is the logic behind this, Absent and tardy are both green, Exited is red and Recycle is yellow?

What if one line have multiple different choices?

Participating Frequently
December 20, 2023

Absent and Tardy would indicate that support documentation is reqired by the participant and shuold be attached to form once completed. However if absent and tardy being the same color is confusing I can elemanate one of them. 

Exited or recycle the participant is no long in the class. 

There should not be mulitiple different choices, however Exited should over ride any other choice.

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
December 20, 2023

Remove all scripts from "PARTICIPANT NAMERow", "INSTITUTIONRow" and "EMPLOYEE IDRow" fields and put this script in one of the fields as custom calculation script  (only one field is enough, it will work on all 5 fields):

for(var i=1; i<=5; i++){
 var PN = this.getField("PARTICIPANT NAMERow"+i);
 var IN = this.getField("INSTITUTIONRow"+i);
 var EM = this.getField("EMPLOYEE IDRow"+i);

 var stp = this.getField("STP-"+i).valueAsString;
 var lop = this.getField("LOP-"+i).valueAsString;
 var lip = this.getField("LIP-"+i).valueAsString;
 var etp = this.getField("ETP-"+i).valueAsString;

 if(stp == "Exited" || lop == "Exited"  || lip == "Exited" || etp == "Exited"){
  PN.fillColor = color.red;
  IN.fillColor = color.red;
  EM.fillColor = color.red;}
 else if(stp == "Tardy" || stp == "Absent" || lop == "Tardy" || lop == "Absent" || lip == "Tardy" || lip == "Absent" || etp == "Tardy" || etp == "Absent"){
  PN.fillColor = color.green;
  IN.fillColor = color.green;
  EM.fillColor = color.green;}
 else if(stp == "Recycle" || lop == "Recycle"  || lip == "Recycle" || etp == "Recycle"){
  PN.fillColor = color.yellow;
  IN.fillColor = color.yellow;
  EM.fillColor = color.yellow;}
 else{
   PN.fillColor = color.transparent;
   IN.fillColor = color.transparent;
   EM.fillColor = color.transparent;}}