Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Contributor ,
Dec 05, 2022 Dec 05, 2022

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

 
TOPICS
How to , JavaScript , PDF forms
600
Translate
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
1 ACCEPTED SOLUTION
LEGEND ,
Dec 05, 2022 Dec 05, 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 ]

View solution in original post

Translate
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
LEGEND ,
Dec 05, 2022 Dec 05, 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 ]

Translate
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
Contributor ,
Dec 05, 2022 Dec 05, 2022
LATEST

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"]; }); }

 

Translate
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