From c1a7be3d6482f8b66fb600faa510491f3d8b477a Mon Sep 17 00:00:00 2001 From: Ahmed Date: Fri, 22 Jan 2021 03:34:43 +0530 Subject: [PATCH] Added Sided by Side hiding based on answer --- JavaScript Files/Side by Side hide.js | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 JavaScript Files/Side by Side hide.js diff --git a/JavaScript Files/Side by Side hide.js b/JavaScript Files/Side by Side hide.js new file mode 100644 index 0000000..c185828 --- /dev/null +++ b/JavaScript Files/Side by Side hide.js @@ -0,0 +1,28 @@ +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[i].hide(); + } + } else { + for (i = st_ans; i < en_ans; i++) { + other_inputs[i].show(); + } + } + } +});