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

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

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

95

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

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

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

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

96

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

Copy link to clipboard

Copied

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
Reply
Loading...
Nov 02, 2018 0