I am using some javascript that allows for radio buttons to be de-selected. The issue I am having is that Qualtrics is still saving the original response even after it is deselected. Does anyone know how to fix this?
`Qualtrics.SurveyEngine.addOnload(function()
{
//initialize values
var prevValue = '';
var exampleForm = document.forms['Page'];
var labels = document.getElementsByTagName('LABEL');
//question click is a simple onclick handler
//attached to the question's container div
this.questionclick = function(event,element)
{
//by default you get the click event as the first parameter and the clicked element as the second parameter
if (element.type == 'radio')
{
//check if the radio was pressed in a row
if (element.id == prevValue)
{
for (var i = 0; i < labels.length; i++) {
if (labels[i].htmlFor == element.id) {
labels[i].className = labels[i].className.replace( /(?:^|\\s)q-checked(?!\\S)/g , '' );
labels[i].className = labels[i].className.replace( /(?:^|\\s)q-focused(?!\\S)/g , '' );
}
}
for( var i=0; i<exampleForm.length; i++ ){
//once found, uncheck it
if(exampleForm[i].id == element.id)
{
exampleForm[i].checked=false;
}
}
//clear temp value
prevValue = '';
}
else
{
//make last pressed button this one
prevValue = element.id;
}
}
}
});`
Best answer by Akdashboard
View original