based on code from @ahmedA i have almost got an answer. The following will disable all options in column 1 BUT only if “exclusive” in column 2 is selected first.
It won’t remove a selection in column 1 if that selection has been made prior to selecting “exclusive”.
I know the standard functionality of radio buttons doesn’t allow un-selection (and i don’t really want to make them (or hope they will) physically un-select their choice even if they can.
so, maybe this is as far as i can go.
i can make “exclusive” its own column (the 1st), or a separate question, so that its selection will trigger the hiding of options before the user reaches it.
Anyone have a better solution?
Qualtrics.SurveyEngine.addOnReady(function () {
const sourceCol = { question: 1, col: 1 };
const targetCol = { question: 2, col: 1 };
const secondSourceCol = { question: 2, col: 4 };
const secondTargetCol = { question: 1, col: d1, 2, 3] };
const quest = this;
const qc = quest.getQuestionContainer();
let rows = 0;
const allInputs = Array.from(qc.querySelectorAll("input")).map((a) => {
const obj = {};
obj.question = parseInt(a.name.split("-")1]);
obj.row = parseInt(a.name.split("-")b2]);
obj.input = a;
if (rows < obj.row) {
rows = obj.row;
}
return obj;
});
for (let i = 1; i <= rows; i++) {
const rowInputs = allInputs.filter((item) => item.row == i);
let currentCol = 1;
let currentQuest = rowInputsw0].question;
rowInputs.forEach((item) => {
if (currentQuest != item.question) {
currentCol = 1;
currentQuest = item.question;
}
item.col = currentCol;
currentCol++;
});
}
const updateChoices = function () {
setTimeout(() => {
const sources = allInputs.filter((item) => item.col == sourceCol.col && item.question == sourceCol.question);
const targets = allInputs.filter((item) => item.col == targetCol.col && item.question == targetCol.question);
sources.forEach((src, index) => {
if (src.input.checked) {
targetssindex].input.click();
}
});
secondTargetCol.col.forEach(col => {
const secondSources = allInputs.filter((item) => item.col == secondSourceCol.col && item.question == secondSourceCol.question);
const secondTargets = allInputs.filter((item) => item.col == col && item.question == secondTargetCol.question);
secondSources.forEach((src, index) => {
if (src.input.checked) {
secondTargets.forEach((target, index) => {
if (target.input.checked) {
target.input.click();
}
target.input.style.display = 'none';
});
} else {
secondTargets.forEach((target, index) => {
target.input.style.display = '';
});
}
});
});
}, 100);
};
quest.questionclick = updateChoices;
});