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.

Fields background color with choice

Avatar

Level 1

Hi everybody, is it possible create a field where you can choose the color of background, like a drop-down list having different colors instead texts.

Other possibilities are allowed.

Thanks a lot

2 Replies

Avatar

Level 6

Here is some simple solution may help you get what you need....

1. Add a text box and name it....ColorTxtField

2. Under Object>>Filed Pallet>>Appearance: select Custom...

3. Custom Appearance Pallet opens up for you to sepecify settings.... select "Background fill>>Style: Solid" and match the fill color to your template background.......................This is key step to get the following code working....

4. Add a dropdown with "Red, Green, Blue" as options to select

then in the change event of the dropdown use the following JS code try it out.

if

(xfa.event.change == "Red") this.parent.ColorTxtField.ui.textEdit.border.fill.color.value = "255,0,0";

if

(xfa.event.change == "Green") this.parent.ColorTxtField.ui.textEdit.border.fill.color.value = "0,255,0";

if

(xfa.event.change == "Blue") this.parent.ColorTxtField.ui.textEdit.border.fill.color.value = "0,0,255";

xfa.layout.relayout();

Now make changes as you needed.

Good luck,

Avatar

Level 1

Hi Varma LC,

do you have an example that can be downloaded?