Text box output not changing based on calculation in another box
- October 15, 2024
- 3 replies
- 377 views
Hi- I have zero JavaScript experience but I'm trying to learn. I am creating a performance evaluation and would like the output of a text box to change based on the score. I've found a few other scripts that seem to do the same, but when I try them (after I adjust my field names, scores, and output text), each of these scripts only displays whatever is in the boxes when the form is opened-- that is, the output does not change if the scores do. So I have checkboxes that when checked make up the score, in a field called "Score". I would like another box to put an output of either "does not meet standards" "good" "exceeds standards" (the output doesn't matter right now, I'm just trying to get the script correct before I build everything else). I've tried these two, and again, they BOTH give the output correctly, but only the first time. How do I get the output to change when the Score field changes? Thank you.
var score = Number(this.getField("Score").valueAsString);
if (score<5) {event.value = "does not meet";} else if (score<=7.5) {event.value = "meets";}
else if (score<=10) {event.value = "Good"}
var calcVal = this.getField("Calc_Score").value;
if(calcVal == "")
event.value = "";
if (Number(calcVal) == 16) {
event.value = "PERFECT!!";
}else if (Number(calcVal) > 11) {
event.value = "PASS";
} else {
event.value = "FAIL";
}
