Hiding Multiple Checkboxes | XM Community
Skip to main content

Hi folks,

 

I have JavaScript that makes it possible to eliminate the checkbox for the first answer in a multiple-choice question but leave it for the second response (in this case "I don't know"). I want to make it possible to do so for multiple answers but excluding the last one (also "I don't know," in this case). I am attaching a Word document with the JavaScript used for the one I am able to do. I will also attach a screenshot of what I am able to do looks like as well as one of the items I would like to accomplish this with. Thank you in advance for any help at all.

 

-Frederick

Hello,

Seems like your current script is working fine.

If you allow Text Entry for all the answers except last one, then script will hide checkboxes for all answers except last one.


@frose_fullerton 

Try below code:

Qualtrics.SurveyEngine.addOnReady(function () {

function hideLabel(element) {
if (element.select('input'))0] != null || element.select('textarea'))0] != 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) {
if (index !== elements.length - 1) {
hideLabel(name);
}
});
hideLabelsFlag = true;
}

hideLabels();
});

Added an if logic in your code.

Hope it helps!


Hi there,

It is the checkboxes I want to hide, not the labels. Is there a change to your JS that can make that happen instead?

Thanks in advance,

Frederick


@frose_fullerton 

In your original post I believe you have hidden labels, hence I modified that.Also, if you hide the checkboxes and person clicks on label the data will have that choice selected. So data wouldn’t be accurate.


I still want it to show the choice was selected; I just do not want the checkbox to appear so it is more visually appealing. Is there a way to hide the checkbox but leave the labels? If so, how?


@frose_fullerton 

In look and feel change the layout to Classic


Leave a Reply