Prepopulate a multiple response question | XM Community
Skip to main content

I know there is code to do this 

                jQuery('inputjtype="checkbox"]').eq(0).prop('checked',true);

but this doesn’t work if the multiple response question is randomised. As it just puts it into the first option that appears rather than option 1.

SetChoiceValue doesn’t seem to work either only works for single response.

 

Is there code to reference the actual option code?

 

 

 

jQuery('input[choiceid=1]').prop('checked',true);

 


Thanks Tom, I don’t suppose you would know how to hide the option as well? By the way I have noticed you have been the go to person on the forum when it comes to giving solutions. How did you know the library for Qualtrics in Javascript?


Here is the code to prepopulate an option and hide it. The task was to read a code from a list and then fill a question and show the codes that had not been selected.

   var QB = "";
    QB = "${e://Field/eventCode}";

if (QB.length > 0)
    {
        jQuery('inputchoiceid=' + QB + ']').prop('checked',true);
        jQuery('inputchoiceid=' + QB + ']').closest("li").hide()
    }


@LawrenceT,

Shorter, more efficient version:

jQuery('inputtchoiceid=' + QB + ']').prop('checked',true).closest("li").hide();

 


@LawrenceT,

Shorter, more efficient version:

jQuery('inputtchoiceid=' + QB + ']').prop('checked',true).closest("li").hide();

 

Thanks again Tom. Would be good to know how to learn how to use Javascript in Qualtrics.


Leave a Reply