I have a PDF form that contains several drop-down boxes containing "_", "Yes", "No", "N/A", and "Other". When the user selects No I want the field to turn red.
Currently I am using the code:
var v = getField("AWA_01").valueAsString;
if (v=="No") {event.target.fillColor = color.red;}
else {event.target.fillColor = color.transparent;}
Where AWA_01 is the name of the first drop-down box. I have also used code:
switch(this.getField("TTS_01").value) {
case "No":
event.target.fillColor = color.red;
break;
default:
event.target.fillColor = color.transparent;
break;
}
Both of these codes execute, but the trouble is that the only options in Adobe for when the code executes are Mouse Up, Mouse Down, Mouse Enter, Mouse Exit, On Focus, and On Blur. Since the "No" is lower in the drop-down box to the point where it is below the main box, the color change does not take affect until you've re-entered the box a second time.
I've tried to add the identical code into the "Will Print" section of the document javascript but it doesn't appear to work. Is there a way to force the code to execute immediately instead of one of those stock mouse options?
I do have the "Commit Selected Value Immediately" turned on, but that doesn't help.
Attach your code to the Format action as a custom format script. Format runs after the value has been committed but before the field is redrawn with the new value.