Count checked boxes leave blank if 0
I am very new to javascript. I learned what I do know right here LOL
I have a form with Monday to Sunday. I have checkboxes for each day. I figured out how to count the checkboxes and return the total number of days checked. However, it puts a 0 when there are none checked. How can I edit my script so it will leave the total blank?
// Initialize counter variable
var sum = 0
// Loop through the fields
for (var i = 1; i < 8; i += 1) {
// Add one if check box is not Off
if (getField("a" + i).value !== "Off") {sum += 1;}
}
// Set this field's value to the sum;
event.value = sum;
