Copy link to clipboard
Copied
Hi,
I searched this forum but couldn't find an answer to my inquiry. I have a Adobe form with a button that I want to change color when the user hovers over it (MouseEnter) and changes color back when the user no longer hovers over it (MouseExit). The button default RGB color is set as 0,0,255. The following Javascript doesn't seem to work. Am I doing something wrong? Thank you!
Mouse enter
event.target.fillColor = (color.equal(["RGB", 0/255,0/255,255/255], event.target.fillColor)) ? ["RGB", 240/255,255/255,255/255] : ["RGB", 0/255,0/255,255/255];
Mouse exit
event.target.fillColor = (color.equal(["RGB", 240/255,255/255,255/255], event.target.fillColor)) ? ["RGB", 0/255,0/255,255/255] : ["RGB", 240/255,255/255,255/255];
Copy link to clipboard
Copied
This type of comparison won't work. But there's is no reason to do it anyway.
Use this:
Mouse enter
event.target.fillColor = ["RGB", 240/255,1,1];
Mouse exit
event.target.fillColor = ["RGB", 0,0,1] ;
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Using custom colors with fractional values is very tricky as they can be adjusted behind the scenes to something else, and then the comparison will fail. I suggest using something else, like the field's tooltip.
Copy link to clipboard
Copied
This type of comparison won't work. But there's is no reason to do it anyway.
Use this:
Mouse enter
event.target.fillColor = ["RGB", 240/255,1,1];
Mouse exit
event.target.fillColor = ["RGB", 0,0,1] ;
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Great, this worked! Thank you.

