Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Is there a way to make the background color of a check box change depending on the state it is in?

Avatar

Level 2

Like: Green background when checked and white (neutral) background while unchecked.  Management wants to draw attention to the boxes that have been selected.

1 Accepted Solution

Avatar

Correct answer by
Level 10

If you create a script object by right-clicking on form1 in your hierarchy (which is the top most subform) and click on Create Script Object and then insert in the script object the function below:

From there in Action Builder, you can use "Call a Script Object Function" then choose your object and choose changeColor function. This should do the trick for ya. This will show or hide background color from your field.

If you want to change the color instead of hiding or showing it you can use this function below and change the RGB value to your liking:

View solution in original post

4 Replies

Avatar

Level 10

You can set a background color to the checkbox under border palette background fill..

You can change the presence of the background color by using :

this.border.fill.presence = "hidden";

or

this.border.fill.presence = "visible";

Change its color value by using

this.border.fill.color.value = "0,255,64";

A good suggestion would be:

1. Create a Script Object in your form and give it a name...

2. Insert this method inside

function changeColor(rootObject){//<--Refers to the object itself (this)

     if (rootObject.rawValue != null || rootObject.rawValue != 0){

          rootObject.border.fill.presence = "hidden";

     } else{

          rootObject.border.fill.presence = "visible";

     }

}

Avatar

Level 2

Thanks, but I am horrible at the scripting.  I was hoping there would be a feature I could use, like the Action Builder.  But that only changes the background color of the Object while it is being clicked, even when I select "is checked".

Avatar

Correct answer by
Level 10

If you create a script object by right-clicking on form1 in your hierarchy (which is the top most subform) and click on Create Script Object and then insert in the script object the function below:

From there in Action Builder, you can use "Call a Script Object Function" then choose your object and choose changeColor function. This should do the trick for ya. This will show or hide background color from your field.

If you want to change the color instead of hiding or showing it you can use this function below and change the RGB value to your liking: