Auto Lock Multiple Choice responses on selection of a particular amount of response | XM Community
Skip to main content

Hi Team, I have a multiple choice question. We have put a answer range on the question, min 0 to max 3. Now respondents can go on selecting as many they want but when they submit they receive an error stating please select 3 responses. 

Can we disable the rest of the options, when 3 responses are selected and before they press submit.

You could try this code:

Qualtrics.SurveyEngine.addOnReady(function () {
const max = 3;
const quest = this;
const qc = quest.questionContainer;

quest.questionclick = function handleClick() {
const selected = [...qc.querySelectorAll(".q-checked.q-checkbox")];
const unSelected = [...qc.querySelectorAll(".q-checkbox:not(.q-checked)")];

[...unSelected, ...selected].forEach(function (item) {
const parent = item.parentElement;
parent.querySelector("input").enable();
parent.style.opacity = "1";
});

if (selected.length >= max) {
unSelected.forEach(function (item) {
const parent = item.parentElement;
parent.querySelector("input").disable();
parent.style.opacity = "0.5";
});
}
};
});

 


Hi Team, I have a multiple choice question. We have put a answer range on the question, min 0 to max 3. Now respondents can go on selecting as many they want but when they submit they receive an error stating please select 3 responses. 

Can we disable the rest of the options, when 3 responses are selected and before they press submit.

Maybe this should help you up with the problem statement…

https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/question-types-guide/standard-content/multiple-choice/


Leave a Reply