Reset selected multiple choice answers when showing same question again | XM Community
Skip to main content

I created a survey where participants answer the same question block multiple times. In between each answer, I store the participant’s responses in some embedded data variables, change some parameters, and then display the same question block again.

However, after the first time participants answer the block, their responses remain selected on the questions for the next time I display the block. How can I reset these using JavaScript?

Here’s what I tried:

Qualtrics.SurveyEngine.addOnload(function() {

// Function to reset choices for a given question
function resetChoices(questionID) {
var choices = jQuery('#' + questionID + ' .q-radio, #' + questionID + ' .q-checkbox');
choices.each(function() {
jQuery(this).prop('checked', false);
});
}

// Reset choices for the specified questions
resetChoices('QID632');
resetChoices('QID631');
});

I’m not sure why this code isn’t properly resetting the multiple choice question. I have a page break between the question containing this JS and the multiple choice questions.

Update, I found a solution that works, although it’s somewhat messy. Added this to the questions that need to be reset:
 

Qualtrics.SurveyEngine.addOnload(function()
{
var qid = this.questionId;
var selectedchoice = 0;
var selected = jQuery("#"+qid).find(".QuestionBody").find("dtype=radio]");
var selectedid = selected.filter(":checked").attr("id");
var parts = selectedid.split("~");
selectedchoice = partsr2];
this.setChoiceValue(selectedchoice, false);
selectedchoice = 0;
});

 


Leave a Reply