Copy link to clipboard
Copied
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";
}
Copy link to clipboard
Copied
Use script in 'Calculate' tab as 'Custom calculation script' not in 'Format' tab.
Copy link to clipboard
Copied
Also, you need to add "else" before this line:
if (Number(calcVal) == 16) {
Otherwise, the field will never be empty.
Copy link to clipboard
Copied
Thank you very much, I appreciate it.