Solved
How to toggle display a question based on the selection from a dropdown question in the same page
Hi,
I want to toggle display an open-end question based on the selection from a dropdown question on the same page. I did manage to do this for a single choice question and below is the code. But again, this is not needed since we have an inpage display logic feature in Qualtrics. Inpage display logic is not supported for dropdown questions thus I am trying to implement it through javascript. The problem here is that I am unable to find the element type and ID for dropdown questions. Let me know if anyone did manage to implement it and if so how could it be done.
Qualtrics.SurveyEngine.addOnload(function ()
{
document.getElementById("QID8").style.display="none";
this.questionclick = function(event,element)
{
console.log(event, element);
if (element.type == 'radio')
{
var choiceNum = element.id.split('~')[2];
var x = document.getElementById("QID8");
if (choiceNum == 479)
{
x.style.display="block";
}
else
{
x.style.display="none";
}
}
}
});
Best answer by npetrov937
There we go:
var x = document.getElementById("QID2") //Question ID of the textbox Q
x.style.display="none"
this.questionclick = function(event, element) {
var selectedChoice = this.getSelectedChoices()
console.log(selectedChoice) //use this to get the value of the choice when you want the textbox to appear
if (selectedChoice == "1") {
x.style.display="block"
}
else {
x.style.display="none"
}
}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
