Return blank if zero
Hello,
I have a form with 5 fields that are drop down boxes. There are 4 choices: Blank (default), Y, N, N/A. I have two fields that produce a calculation. One returns '# of #' and the other produces a % of Y's.
In the default state of blank, the calculations are '0 of 0' and '0%'. The problem is that, unfortunately, some providers will want a printed hardcopy to fill out and the fields have these zero's in them.
How can I make the field so blank? I have tried several variations to no avail.
1st script '0 of 0':
var totalY = 0;
var total = 0;
for (var i=1; i<=5; i++) {
var f = this.getField("JJCRDropdown"+i);
if (f.valueAsString=="Y") {
totalY++;
total++;
} else if (f.valueAsString=="N") {
total++;
}
}
if (total==0) event.value = "";
else event.value = totalY / total;
2nd script '0%':
var totalY = 0;
var total = 0;
for (var i=1; i<=5; i++) {
var f = this.getField("JJCRDropdown"+i);
if (f.valueAsString=="Y") {
totalY++;
total++;
} else if (f.valueAsString=="N") {
total++;
}
}
if (total==0) event.value = "";
else event.value = totalY / total;
