Retrieving the number of checkboxes | XM Community
Solved

Retrieving the number of checkboxes

  • 1 December 2018
  • 2 replies
  • 68 views

There is a question on my form that involves a multiple check boxes that a user can check.

For that question, I need to retrieve a value for the amount of check boxes the user selects (if a user checks 3 boxes, I would need to have a value of 3 outputted to a variable). Since I would need this value for formulas, I would need to set this value into as an embedded data.

How should I retrieve that value?
icon

Best answer by Anonymous 1 December 2018, 00:49

View original

2 replies

Hello @sPham ,

Step1: Make an embedded data(SelectedChoiceCount) in survey flow before the multiple check boxes question

Step2: Paste the below code in the one previous question (js option) to the multiple check boxes question.

var that=this.questionId;
jQuery("#"+that+" input[type='checkbox']").on('change',function(){
var s= jQuery("#"+that+" :input[type='checkbox']:checked").length;
Qualtrics.SurveyEngine.setEmbeddedData( 'SelectedChoiceCount', s );
});

Step 3: Use embedded data 'SelectedChoiceCount' where required.
This is perfect! Thanks for the steps!

Leave a Reply