These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Font Color in a Combo Box

Lady Di
Registered: Feb 18 2009
Posts: 86
Answered

How can I change the font color in a combo box based on the selection made? If Yes is selected in the combo box, I want the text color to turn to dark blue and the fill color to turn to pale blue. Below is the code I tried to use, but it is not working. No matter what I pick in the combo box, the text stays black.

if (event.willCommit) { getField("UnitDown").textColor = (event.value === "Yes")
? this.textColor = [color.blue]:
this.textColor = [color.black]; }

Any assistance you can provide would be greatly appreciated.

My Product Information:
Acrobat Pro 8.0, Windows
nixopax
Registered: Feb 6 2009
Posts: 105
if (event.willCommit){this.getField("test").textColor = (event.value === "Yes")? color.blue:color.black;}

Added "this." before the getField().
Removed [] square brackets surrounding colour arrays.
Also, since you're setting a variable with a ternary outcome, it's best not to try to set something else as the variable value.
rkpdfmaker
Registered: Jul 29 2010
Posts: 8
Hi, this code looks like it's exactly what I'm looking for but can't get it to work. I have the state in the combo box set to 'Mouse Down', selected run a javascript and put the above script in but I can't get it to work. Ideally I would like the text to stay the same colour and just the fill colour to change to red or green depending on a Yes or No answer. Any ideas what I'm doing wrong here?

rkpdfmaker
designer