Skip to main content
Inspiring
May 5, 2016
Answered

Custom Format Scrip

  • May 5, 2016
  • 2 replies
  • 683 views

I hope I've posted this in the right place, I'm working on a form in Adobe Acrobat 9.  I have a combo box in a form, with Low, Medium, High and No Action Required as the options.  What I would like to do is change the colour of the field (either text or background) based on the selection such as

Low - Green

Medium - Orange

High - Red

No Action Required - no change.

Can this be done?

This topic has been closed for replies.
Correct answer George_Johnson

If you mean that you want to change the background color of the combo box, you can use the following custom validate script:

// Custom Validate script for text field

switch (event.value) {

case "Low" :

    event.target.fillColor = color.green;

    break;

case "Medium" :

    event.target.fillColor = ["RGB", 1, .33, 0];

    break;

case "High" :

    event.target.fillColor = color.red;

    break;

case "No Action Required" :

    event.target.fillColor = color.white;

    break;

}

2 replies

Participant
September 22, 2016

Hi, I am hoping you can help me. Your code worked perfectly! The only problem is, I am trying to change the RGB to colors that match my pdf. Your example RGB works great, however when I insert my RGB it doesn't work at all and I can't figure out why.

Here is my code:

// Custom Validate script for text field

switch (event.value) {

case "Yes" :

    event.target.fillColor = color.green;

    break;

case "No" :

    event.target.fillColor = ["RGB", 1, .33, 0];

    break;

case "1 x per week" :

    event.target.fillColor = ["RGB", 146, 200, 78];

    break;

case "select one" :

    event.target.fillColor = color.gray;

    break;

}

The event.target line in NO is your code and it changes to red. the event.target line in 1x per week is the green color I am using elsewhere in my pdf, but when I select 1 x per week, it goes white. Any ideas?

Inspiring
September 22, 2016

The individual numbers in the array range from 0 to 1, not 0 to 255, so use this instead:

    event.target.fillColor = ["RGB", 146/255, 200/255, 78/255];

George_JohnsonCorrect answer
Inspiring
May 5, 2016

If you mean that you want to change the background color of the combo box, you can use the following custom validate script:

// Custom Validate script for text field

switch (event.value) {

case "Low" :

    event.target.fillColor = color.green;

    break;

case "Medium" :

    event.target.fillColor = ["RGB", 1, .33, 0];

    break;

case "High" :

    event.target.fillColor = color.red;

    break;

case "No Action Required" :

    event.target.fillColor = color.white;

    break;

}

EllenBCCAuthor
Inspiring
May 5, 2016

Thank you so much, it now works perfectly, you've made my day