Retrieving the number of checkboxes | XM Community
Skip to main content
Solved

Retrieving the number of checkboxes

  • November 30, 2018
  • 2 replies
  • 145 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?

Best answer by Anonymous

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.

2 replies

  • Answer
  • November 30, 2018
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.

  • Author
  • December 4, 2018
This is perfect! Thanks for the steps!