Sum of integer values in a matrix question

Compatibility: IdSurvey 6 IdSurvey 7

The script returns the algebraic sum of integer values (both positives and negatives) in a matrix question, by adding each numerical open-ended answer in a column and displaying the result the end of it.


  • The page on which the script is applied must contain only a single matrix question.
  • The script is not compatible with 3D matrixes and simple matrixes with more than one column when filling a CAWI survey from smartphone.


Copy the following script in the Client script box. You will find it in the gearwheel button of the page containing the matrix.

<script type="text/javascript">
      $(".grid-question-table tbody").append('<tr><td> </td><td><div><input type="text" class="ignoreinput" id="total" readonly="readonly" ></div> </td></tr> ');
      $(".grid-question-wrapper :text, .grid-question-wrapper input[type='number']:not(.ignoreinput)").off("keyup change").on("keyup change", function(){
    $(".grid-question-wrapper :text, .grid-question-wrapper input[type='number']").trigger("keyup");
    function count(){
        var cnt = 0;
        $(".grid-question-wrapper input:not(.ignoreinput)").each(function (){
            var num = parseInt($(this).val());
            if (!isNaN(num)) cnt = cnt + num;
        return cnt;


Leave A Comment?