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

New Here ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

102

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

LEGEND , Nov 02, 2018 Nov 02, 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.

Likes

Translate

Translate
LEGEND ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines