Hi everyone,
In sbs question I have 3 options, option1 and option2 are text entry option, and option3 is a radio checked
I want to hide options 2 and 3 if the respondent enters 0 in the first option.
How can I set-up this? Using JavaScript? Does somebody have an example?
This should do what you are looking for:
Qualtrics.SurveyEngine.addOnReady(function () {
n_choices = this.getChoices().length;
q1_input = this.getQuestionContainer().querySelectorAll(".SBS1.AnswerCell Input");
q1_input.forEach((box) => {
box.oninput = function () {
get_val(box.name, box.value);
};
});
other_inputs = this.getQuestionContainer().querySelectorAll(".AnswerCell:not(.SBS1)");
n_answers = other_inputs.length / n_choices;
function get_val(el_name, el_value) {
row_num = Number(el_name.split("~")2]) - 1;
st_ans = row_num * n_answers;
en_ans = (row_num + 1) * n_answers;
if (el_value == "0") {
for (i = st_ans; i < en_ans; i++) {
other_inputs }
} else {
for (i = st_ans; i < en_ans; i++) {
other_inputsi].show();
}
}
}
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.