Please help.
I have (5) combo boxes named "Rating 1, Rating 2", etc...I then have a Text Field entitled "Score". I'm trying to calculate the average score of the 5 combo boxes. However if a combo box is left blank, the text field "score" is still averaging the "zero". How can you get it not to average unless a figure is displayed?
Also- is there a way to create a "blank" option under "options" under the combo box property mode?
To calculate the correct average, you'll have to use JavaScript. You can then check the field value, and if it is equal to the "blank" value, exclude it from the calculation. For example:
// Custom calculate script for text field
(function () {
var v;
var count = 0;
var sum = 0;
// Loop through combo boxes
for (var i = 1; i < 6; i++) {
v = getField("Rating " + i).value;
if (v !== " ") {
count++; // Increment counter
sum += v; // Add value to sum
}
}
// Calculate average
if (count) {
event.value = sum / count;
} else {
event.value = "";
}
})();