Retrieving the number of checkboxes | XM Community
Skip to main content
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?
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