Hello W. Dean,
I hope this helps you.
On Click Event (button)
// I establish the state of the button depending on the text that it contains
// You can use the button's background color or its text color too.
var buttonText = xfa.resolveNode("this.caption.value.#text").value;
// Check the condition.
if(buttonText == "ADD COMMENT"){
// Changing the caption of the button's text.
xfa.resolveNode("this.caption.value.#text").value = "CLEAR COMMENT";
// Changing the text color to black.
this.caption.font.fill.color.value = "0,0,0";
// Changing the button's background color to red.
this.fillColor = "255,0,0";
}else{
xfa.resolveNode("this.caption.value.#text").value = "ADD COMMENT";
this.caption.font.fill.color.value = "255,255,255";
// white
this.fillColor = "20,120,220";
//blue
}
Good luck,
Dan