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.
Page 1 / 1
Hi there,
yes, this is doable.
- add the class .lineThrough{text-decoration:line-through;} in the look and feel section ->style -> custom css
- 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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.