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

Fill colour in combo box

rkpdfmaker
Registered: Jul 29 2010
Posts: 8
Answered

Hi, I have a combo box with the options 'Yes' or 'No' in a list. I need a javascript which changes the fill colour to red or green depending on the answer given. At the moment I have this but can't make it work:

if (event.willCommit)
{
this.getField("test").fillColor = (event.value === "Yes")? color.black:color.red;
this.getField("test").fillColor = (event.value === "No")? color.black:color.green;
}

Any help would be appreciated.

rkpdfmaker
designer

My Product Information:
Acrobat Pro 9.0, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You need to set the option to commit the value immediatly and then you need to create a custom format keystroke script:
// clear fill colorevent.target.fillColor = color.transparent;// for Yes selectionif (event.value == "Yes") event.target.fillColor = color.green;// for No selectionif (event.value == "No") event.target.fillColor = color.red;

While one is within a field, it is best to use the 'event' object to access that object.

George Kaiser