Display logic not working on a previous autofilled questioned | XM Community
Skip to main content

I have used Javascript to autofill a question and have checked that it is auto-filling. However, when I go to use the auto-filled question in a display logic for the next question. The display logic is not working.

This is the script I used to autofill.

 

Qualtrics.SurveyEngine.addOnload(function()
{
    var TT1 = "${q://QID26/SelectedChoicesRecode}"; 
    if (TT1 =="2" || TT1=="5" || TT1=="6" || TT1=="7" || TT1=="8" || TT1=="9" || TT1=="11")
    {
        for (var i = 0; i < 3; i++) {
            jQuery('inputtype="checkbox"]').eq(i).prop('checked',true)       
        }
         jQuery("#"+this.questionId).hide();
    }
});

Qualtrics.SurveyEngine.addOnReady(function()
{
    
    var TT1 = "${q://QID26/SelectedChoicesRecode}"; 
    if (TT1 =="2" || TT1=="5" || TT1=="6" || TT1=="7" || TT1=="8" || TT1=="9" || TT1=="11")
    {
         this.clickNextButton();
    }

});
 

 

 

This has been resolved there was another javascript that was affecting it. But if anyone has tips of how to write this better.


There is a much better way. 

Qualtrics.SurveyEngine.addOnload(function()
{
    var TT1 = parseInt("${q://QID26/SelectedChoicesRecode}"); 
    if (2,5,6,7,8,9,11].includes(TT1))
    {
        for (var i = 0; i < 3; i++) {
            jQuery('inputtype="checkbox"]').eq(i).prop('checked',true)       
        }
         jQuery("#"+this.questionId).hide();
    }
});Qualtrics.SurveyEngine.addOnReady(function()
{
    
    if(jQuery(this.questionId).val)  this.clickNextButton();


    }});


Leave a Reply