• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Dec 09, 2021 Dec 09, 2021

Copy link to clipboard

Copied

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. 

TOPICS
Windows

Views

117

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

LATEST

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines