I've got a side-by-side single statement question with a text entry box and 2 mutually exclusive checkboxes. I've got custom validation in place that prevents a respondent from entering a value AND selecting a response. What I'd really like is to write some custom code where if someone enters a value, the boxes are automatically unchecked. And if someone checks a box, any value already entered is cleared. I've already got code (below) that makes the 2 boxes mutually exclusive, and it seems like it would be simple enough extension of this if I understood jquery better, but I don't know what commands to use. Thank you!
this.questionclick = function(event,element){
if(element.id=='QR~QID3#2~1~1')
{
document.getElementById('QR~QID3#2~1~2').checked=element.unchecked;
}
if(element.id=='QR~QID3#2~1~2')
{
document.getElementById('QR~QID3#2~1~1').checked=element.unchecked;
}
}
!
Page 1 / 1
I figured out the onclick function to set the text entry to null if either of the boxes are checked, but can anyone help with the piece that will uncheck the boxes if the text entry value is changed? Thank you!
`Qualtrics.SurveyEngine.addOnload(function()
{
this.questionclick = function(event,element){
document.getElementById('QR~QID2#2~1~2').onclick = function(){
document.getElementById("QR~QID2#1~1~1~TEXT").value = "";
}
document.getElementById('QR~QID2#2~1~1').onclick = function(){
document.getElementById("QR~QID2#1~1~1~TEXT").value = "";
}
});`
`Qualtrics.SurveyEngine.addOnload(function()
{
this.questionclick = function(event,element){
document.getElementById('QR~QID2#2~1~2').onclick = function(){
document.getElementById("QR~QID2#1~1~1~TEXT").value = "";
}
document.getElementById('QR~QID2#2~1~1').onclick = function(){
document.getElementById("QR~QID2#1~1~1~TEXT").value = "";
}
});`
I would also find this additional code to be super useful, thanks Nadaly for the code that you already provided!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.