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

Changing colors of text in Combo box with a calculation

Squatty
Registered: Jan 12 2011
Posts: 2

I seek help on a script. I have a text field that calculates the sum of some text boxes. Then I have a combo box with three choices: A, B and C. The default value is A. What I would like to do is this: If the number in the text field is 0-9 I would like the combo box to switch to B without the user having to do anything. Then if the number in the text text field is 10 or greater, I would like the combo box to switch itself to C and maybe even turn a different color text.
 
Does this make sense?

My Product Information:
Acrobat Pro 9.4, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Very doable. If the combobox is named "MyCombo", And there are no Export values defined, then this script will automatically set the value and color.

This is the calculation script for the text field.
**************************

event.value = ... The calculation ...

vvar oComboFld = this.getField("MyCombo");

if((event.value > 0) && (event.value < 10))
{
oComboFld.value = "B";
oComboFld.fillColor = color.red;
}
else if(event.value >= 10)
{
oComboFld.value = "C";
oComboFld.fillColor = color.green;
}
else
{
oComboFld.value = "A";
oComboFld.fillColor = color.white;
}

*************************



Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script