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.

Changing the color of Buttons back and forth

Avatar

Level 3

Hi,

I've created a form and I have placed a button that I need to change color and text once clicked. The problem I have is that I want to make a second click to make the button go back to the previous state. So, basically the button should have two "stages". At first it should appear white and the caption on it should read something, and once I click, the color and caption should change but I want to be able to make go back to its original state by cliking on it once again.

I have used the following code under the "click" function but it only works one way.

this.resolveNode("caption.value.#text").value = "Available";
this.fillColor = "55,55,55";

Thank you for your help!!!!!

1 Reply

Avatar

Level 6

try the following....

if

(this.resolveNode("caption.value.#text").value != "Available") {

     this.resolveNode("caption.value.#text").value

= "Available";

     this.fillColor

= "55,55,55";

}

else {

     this.resolveNode("caption.value.#text").value

= "NotAvailable";

     this.fillColor

= "255,255,255";

}