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

Retrieving the number of checkboxes

  • Nov 30, 2018 11:02 PM UTC
  • 2 replies
  • 180 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.
View original

2 replies

  • Answer
  • Nov 30, 2018 11:49 PM UTC
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
  • Dec 4, 2018 9:22 PM UTC
This is perfect! Thanks for the steps!