Java script needed to count form fields with text and ignore empty fields for Acrobat Pro

What is the Java script that is needed for box4 to reflect the count of the number of x's in the form fields box1, box2, box3 disregarding any the blank form fields? In this sample, the form fields are labeled box1, box2, box3, and box4 left to right.
I have found the java script below but do not know where to substitute box1, box2, box3, and box4 or what will need to removed from this java script.
var total = "";
for (var i=1; i<=28; i++) {var f = Number(this.getField("Rating"+i).valueAsString);
if (f > 0 && f <= 4) total++;} event.value = total;
Thank you for your assistance!!
Janelle
