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

display "FAIL" in textbox field and change textcolor to red if average is below 15

xtnsvdamage
Registered: Oct 27 2010
Posts: 2
Answered

Elements:
1) p05_8_Average is a textbox with an average calc function
2) Below is custom Calculation Script for textbox named p05_8_PASSFAIL.
 
====================
var nAverage = this.getField("p05_8_Average").value;
If (nAverage>=15)
{ event.value="PASS";
event.target.textcolor=["G",1];
}
Else
{ event.value="FAIL";
event.target.textcolor=["RGB",1,0,0];
}
====================
 
Condition:
Textbox p05_8_PASSFAIL should display FAIL in red if average is below 15.
 
Result:
the textbox is not updating for some reason whether the average passes or fails. It just stays blank.
  

My Product Information:
Acrobat Pro Extended 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
That code should be showing errors in the JavaScript console. In JavaScript, case is significant. Try the following:

var nAverage = +getField("p05_8_Average").value;

if (nAverage >= 15) {
event.value = "PASS";
event.target.textColor = ["G", 1];
} else {
event.value = "FAIL";
event.target.textColor = ["RGB", 1, 0, 0];
}
xtnsvdamage
Registered: Oct 27 2010
Posts: 2
Thanks George! That definitely solved it!