Calculating NPS (or tabulating scores in a form) for a survey

If you are using checkboxes for your survey, you can set values for the individual items in a checkbox


Adding a hidden field as a total and using Javascript to keep the hidden field up to date will allow you to sum totals of a form's quiz

If you're using checkboxes:


  var update_total = function(){
    var total = 0;
    $('%FORM.HTML_ID% .checkbox input[type=checkbox]:checked').each(function(){
      total += parseInt($(this).val());
    });
    $('%FORM.HTML_ID% input[type=hidden].activedemand-input').val(total);
  };
  $('%FORM.HTML_ID% .checkbox').each(function(){
    $(this).on("click", update_total);
  });
  update_total();


If you're using radio buttons

  var update_total = function(){
    var total = 0;
    $('%FORM.HTML_ID% .radio input[type=radio]:checked').each(function(){
      total += parseInt($(this).val());
    });
    $('%FORM.HTML_ID% input[type=hidden].activedemand-input').val(total);
  };
  $('%FORM.HTML_ID% .radio').each(function(){
    $(this).on("click", update_total);
  });
  update_total();


Consider posting the hidden field to a custom field on the contact

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.