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

Display logic not working on a previous autofilled questioned

  • October 13, 2023
  • 2 replies
  • 39 views

Forum|alt.badge.img+2

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('input[type="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();
    }

});
 

 

 

2 replies

Forum|alt.badge.img+2
  • Author
  • Level 1 ●
  • 11 replies
  • October 13, 2023

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


Forum|alt.badge.img+2
  • Author
  • Level 1 ●
  • 11 replies
  • October 18, 2023

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('input[type="checkbox"]').eq(i).prop('checked',true)       
        }
         jQuery("#"+this.questionId).hide();
    }
});Qualtrics.SurveyEngine.addOnReady(function()
{
    
    if(jQuery(this.questionId).val)  this.clickNextButton();


    }});