Starting with Acrobat JavaScript can be overwhelming. The documentation is important, and the complete set which is IMHO needed is about 1500 pages… you don't have to read and understand everything to begin with, but there is a lot of reading.
Anyway, the first thing to look at is what you would want to accomplish. Field value and event.value are referring to the value of the field, and only to the value of the field. As you see, the base of the logic does work, because it displays the color names you have assigned.
However, the logic has "holes", which do not cover certain values, such as between 8.9 and 9, or greater than 10. We assume that the entered value is in fact convertible to a number (otherwise, we would first have to check for that). Then we sort out the numbers outside of the valid range (greater than 10 and smaller than 0); in order to distinguish that, we make the border black. Of what remains to be checked we take anything greater than 9 (we don't have to worry about greater than 10, because we already took care of that), and make the green border. Next step is greater than 8 of what remains, and make the yellow border. And finally, what remains will get a red border.
In order to change the border color, we have to use another property of the field, namely the strokeColor property. And we have to get the color specified. The latter is easy because Adobe has already a few colors pre-defined in the Color object.
That would lead to the following script in the Calculate event of the "Scale" field:
var score = this.getField("Score").value*1 ;
if (score > 10 || score < 0) {
app.alert("invalid score") ;
event.target.strokeColor = color.black ;
} else {
if (score >= 9) {
event.target.strokeColor = color.green ;
} else {
if (score >= 8) {
event.target.strokeColor = color.yellow ;
} else {
event.target.strokeColor = color.red ;
}
}
}
And that should get you already quite far.
Hope this can help.
Max Wyss.