Strikethrough statement when checkbox is selected? | XM Community
Skip to main content

I want to use Qualtrics to create a checklist of sorts. I was planning to use multiple choice multiple response questions but was wondering if there was some javascript that would automatically strikethrough the list item once someone clicks the checkbox. This would be the same behavior as checklists in Google Docs.

image.png

Hi there,
yes, this is doable.

  1. add the class .lineThrough{text-decoration:line-through;} in the look and feel section ->style -> custom css

  2. add the below javascript to the respective question

Qualtrics.SurveyEngine.addOnload(function()
{
this.questionclick = function(event,element)
    {
       
        if (element.type == 'checkbox')
        {
            let choiceId = element.id;
console.log(choiceId)
let selectedChoiceId  =  choiceId.split('~')2]
let lw = document.getElementById(this.questionId+'-'+selectedChoiceId+'-label') //get the label element
let ls = lw.getElementsByTagName('span') // get the span element where the label text is
console.log(ls)

if(element.checked == true){
lse0].addClassName('lineThrough') //if choice is selected add class

}else{

lsl0].removeClassName('lineThrough') //if choice is deselected remove class
}
           
            
        }
    }
});

Please note that this will work with the flat layout
Best regards

Rudi


Rudi Works great! Thank you.


Leave a Reply