Automatically selecting an answer option even if it wasn't selected by the respondent | XM Community
Skip to main content

I have a question where we ask respondents which programs they are a member of. All of the respondents are members of a specific program. How can I make sure that the specific program is selected for those respondents who forgot to select it?
For example:
Q1 has A, B and C programs as answer options.
All respondents are actual members of the C program.
Respondent only selected A and clicked on Next.
Before moving to the new question, I need to add C as a selection for Q1
Thanks.

You could make C a default choice and it would be automatically selected. They would be able to deselect it.
Alternatively, you could use JS to select it in the addOnPageSubmit function.


Do you have a sample code? This is my first time programming in Qualtrics after transitioning from Confirmit.

Thanks.


This is my code. It's not working. 2 is the precode of the answer option that I want to auto-select.
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
/*Place your JavaScript here to run when the page is unloaded*/

var valQ8= "${q://QID9/SelectedChoicesRecode}";
var found = 0;
var arrQ8 = new Array();
arrQ8 = valQ8.split(",")

for(var i=0; i if (arrQ8[i]==2)
found = 1;
}
if (found = 0) { 
this.setChoiceValueByRecodeValue(2,true); 
}
});


You are making it more complicated than needed. If you want to always select the choice with recode 2, then:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
this.setChoiceValueByRecodeValue(2,true);
});


Thanks!


Leave a Reply