Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Sample-SurveyItemAverage.nitro_s

When your survey answers have numeric saved values you might have a situation where you want to calculate the average of all the choices the user selected.

Included here is a javascript javaScript function that can be used to accomplish that task.

The function is in the Settings...Events

...

The F_Number is the ID of the field where the average is being placed.Note:


Info
 Because the work is done by a function you could re-use the function in your form if you had multiple survey items and wanted to calculate the average of each. 


A few assumptions have been made for this function:

 1. The average is taken on all the questions in the survey item whether they are answered or not.  You could modify the function if you wanted to only take the average of "answered" questions, however I assume that all the questions would be answered, which is why I didn't implement it.

2.  The saved value of the survey item choices must be numbers.  The function doesn't check and may produce a strange result if you tried this with non-numeric saved values.

...