I think you should change the formula the following way, to get the
right results. var Fields = xfa.resolveNodes("CommRtng[*]"), Answered =
0, Values = 0, Rating = 0, i; for (i = 0; i < Fields.length; i += 1){ if
(parseInt(Fields.item(i).rawValue, 10) > 0) { Answered += 1; Values +=
parseInt(Fields.item(i).rawValue, 10); } } Rating = 100 / (Answered * 5)
* Values this.rawValue = Rating; To fire this calculation just once, put
the script into a click event of a button so it's executed only when t...