Auto-fill color dropdown

New Here ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

I am trying to get my dropdowns to auto-fill with yellow when someone chooses "N" or No but do not like the harsh generic yellow.  I have tried to research how to enter one of the other colors by using their RGB on a 0-1 scale.  My question is where would I need to insert the RGB in my current script:

 

event.target.fillColor=(this.getField("Dropdown35").valueAsString=="N")? color.yellow:color.transparent;

 

And how should I enter it? All the forums I have read have =["RGB",value,value,value] 

 

Thank you!

TOPICS
Create PDFs , General troubleshooting , How to , JavaScript

Views

110

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
Adobe Community Professional ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

Just replace color.yellow with what you found, so something like this:

 

event.target.fillColor=(this.getField("Dropdown35").valueAsString=="N")? ["RGB",255/255,255/255,224/255] : color.transparent;

 

This will result in a light yellow color.

 

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
New Here ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

I am getting a Syntax error when I try that.

 

CrockettKnox_0-1649803901823.png

 

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
New Here ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

So I see you removed the word color. before the color calculations but now I have run into another problem.  It highlights the box with every selection when I only want it to highlight when "N" is chosen.  But the good news is the yellow is correct.  Any thoughts on why it might be highlighting all the selections now just because I removed color.?

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
Adobe Community Professional ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

You can't use color.["RGB",255/255,255/255,224/255]

use only ["RGB",255/255,255/255,224/255].

Script should work fine, where did you use it? Did you check 'Commit selected value immediately' under dropdown field -> options tab?

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
New Here ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

I am kinda new to Adobe and very new to Java but I have the script under the "Calculate Tab" and in the "Custom Calculation Script".  I tried checking the box you indicated in your message but no change.  I have the right color yellow now but I just need it to be yellow when someone marks "N" and not all the time.  It was working with the old yellow and when I had "color." in the script.  Not sure what adjustment I need to make.  Thank you for your help!

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
Adobe Community Professional ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Post your code or share the actual file with us, please.

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
New Here ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

CrockettKnox_0-1649952703605.png

 

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
Adobe Community Professional ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Seems fine to me. If it's not working share the file.

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
New Here ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

So it's working for me now.  I decided to back out of the file and reopen it, working great.  Again, thank you for your help

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
New Here ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

The last question, I have this set to change color when "N" is selected how do I indicate a color change in the same dropdown for a different selection.  Some of my dropdowns have "N" and "Pending" that I would like both to change color for. 

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
Adobe Community Professional ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

LATEST

That requires a somewhat different construction of the code:

 

var s = this.getField("Dropdown35").valueAsString;
if (s=="N") event.target.fillColor=["RGB",255/255,255/255,224/255];
else if (s=="Pending") event.target.fillColor=["RGB",100/255,66/255,150/255];
else event.target.fillColor=color.transparent;

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