Skip to main content
staceyk420
Participant
November 2, 2018
Answered

Javascript to change the background color a custom color to based on user input.

  • November 2, 2018
  • 1 reply
  • 621 views

I am trying to create a javascript to change the color to a custom color based on value input.

The only color that seems to work is the value 4 which turns it yellow.  The other values are not working.  Any suggestions:

This is what I have:

if (event.value=="1") event.target.fillColor = ["RGB", 253, 215, 240]; 

else if (event.value=="2") event.target.fillColor = ["RGB", 198, 224, 180]; 

else if (event.value=="3") event.target.fillColor = ["RGB", 204, 236, 255];

else if (event.value=="4") event.target.fillColor = ["RGB", 255, 255, 0];

else event.target.fillColor = color.white;   

TIA

This topic has been closed for replies.
Correct answer gkaiseril

As explained in the Acrobat JS Reference, the color values in a color array range from 0 to 1 inclusively. So you need to map the values from 0 to 255 to the range 0 to 1.

1 reply

gkaiserilCorrect answer
Inspiring
November 2, 2018

As explained in the Acrobat JS Reference, the color values in a color array range from 0 to 1 inclusively. So you need to map the values from 0 to 255 to the range 0 to 1.