In my questionnaire, I'm using a lot of text entry questions with a “Don't know”-option. To do so, I've made use of the JavaScript written by
Qualtrics.SurveyEngine.addOnReady(function () {
function hideLabel(element) {
if (element.select('input')p0] != null || element.select('textarea')r0] != null) {
element.select('label').each(function (a, b) {
a.hide();
});
} else {
console.log(element);
}
}
var hideLabelsFlag = false
function hideLabels() { //QH.hideLabels() - Hides the label for any answer option where a text input has been added.
var elements = $$('.LabelWrapper');
elements.each(function (name, index) {
hideLabel(name);
});
hideLabelsFlag = true;
}
hideLabels();
});
However, the JavaScript seems to be applied to all questions on the same page as the question to which it is added. So, for example, on some pages the text entry questions with the JS are followed by multiple choice questions with an ‘other’ answer category, where people can enter text. In this case, the ‘other’ option in the multiple choice question disappears as well, even when the JS is not added to this specific multiple choice question.
Is there a way to adapt the JS in such a way that it only applies to the specific question to which it is added?
I’ve tried to rewrite the JS myself but I'm afraid my skills are insufficient to tackle this issue…
Any help is much appreciated!