Skip to main content
itgse
Participating Frequently
December 9, 2021
Question

Assigning background colors to different text fields depending on check box status

  • December 9, 2021
  • 1 reply
  • 210 views

Sorry new to Java Script and hoping someone can help me. I have three specific check boxes if any one or combination of those three boxes are check I want textfield1 to have a black background. If all text boxes are unchecked I want textfield2 to have a black backgound. Currently the background colors for both of those fields are set to none. 

This topic has been closed for replies.

1 reply

ls_rbls
Community Expert
December 22, 2021

You can try with a custom calculation script.

 

In the example below, I've placed  the  custom script in "textfield1":

 

var field1 = event.target;
var field2 = this.getField("textfield2");
var cb1 = this.getField("Check Box1").value;
var cb2 = this.getField("Check Box2").value;
var cb3 = this.getField("Check Box3").value;

field1.fillColor = (cb1 !=="Off" || cb2 !=="Off" || cb3 !=="Off") ? color.black : color.transparent;

field2.fillColor = (cb1 =="Off" && cb2 =="Off" && cb3 =="Off") ? color.black : color.transparent;