reset button not fully working | XM Community
Skip to main content

Hello coders,
I have a question in the survey where participants can select multiple choices. I have also provided a reset (clear all) button in case participants want to re-select or change their choices. However, when I click on this button, it is not completely clearing the choice. Only the color changes from blue to grey. Here's the JS and HTML codes I have used.
HTML:
JS:
Qualtrics.SurveyEngine.addOnload(function() {
 var qobj = this;
 var q = jQuery("#"+qobj.questionId);
 var inputs = q.find(".QuestionBody").find("dtype=checkbox]");
 q.find(".reset").click(function() {
 inputs.filter(":checked").each(function() {
  var parts = this.id.split("~");
  qobj.setChoiceValue(partsl2],parts[3],false);
 });
 });
});
image.png

Hi sajjid,
You are so close, there is only one line that is wrong :)
//won't work
var inputs = q.find(".QuestionBody").find("[type=checkbox]");

//should work
var inputs = q.find(".QuestionBody").find("[role=option]");
The "select box" option that you're using is defined a bit differently to the typical multiple choice checkboxes.
Good luck!


Thank you, bgooldfed! it worked


Thank you so much bgooldfed for assisting with the code and finding a working solution! 🙂


Leave a Reply