Skip to main content
Saher Naji
Inspiring
December 5, 2022
Answered

Change the color to RGB or hex system in Document JavaScript Code

  • December 5, 2022
  • 2 replies
  • 752 views

Hello,

 

I have this Document JasvaScipt code:

function SetLayerStateFromRadioButton(){ event.target.exportValues.forEach(function(cVal,i){ oWidget = this.getField(event.targetName + "." + i); oWidget.lineWidth = (cVal == event.value)?1:0; oWidget.borderColor = (cVal == event.value)?color.green:["T"]; }); }

How can I change the green color to a dark green, this exact color: ["RGB", 40/255, 114/255, 79/255]

 

Here it is with the hex system #28724F

 

Thank you

 
This topic has been closed for replies.
Correct answer Test Screen Name

You seem to already have an exact colour, you quote it. ["RGB", 40/255, 114/255, 79/255], which is a color array

So I don't understand what you mean by "change" or "convert". You can use whar you already have in place of color.green, since borderColor wants a color array, and color.green is just shorthand for the color array [ "RGB", 0,1,0 ]

2 replies

Saher Naji
Inspiring
December 5, 2022

Thank you, it's working, in fact I did not know where to add ["RGB", 40/255, 114/255, 79/255],

I put it after the color.green, but now I replace it with color.green

 

Here is the updated code, and it's working

function SetLayerStateFromRadioButton(){ event.target.exportValues.forEach(function(cVal,i){ oWidget = this.getField(event.targetName + "." + i); oWidget.lineWidth = (cVal == event.value)?1:0; oWidget.borderColor = (cVal == event.value)?["RGB", 40/255, 114/255, 79/255]:["T"]; }); }

 

Test Screen NameCorrect answer
Legend
December 5, 2022

You seem to already have an exact colour, you quote it. ["RGB", 40/255, 114/255, 79/255], which is a color array

So I don't understand what you mean by "change" or "convert". You can use whar you already have in place of color.green, since borderColor wants a color array, and color.green is just shorthand for the color array [ "RGB", 0,1,0 ]