Target one multiple choice question and select radio button via jQuery | XM Community
Skip to main content

Hi There,

I'm almost there, but I just cannot figure out the last part. I want to get the value from the embedded data field and let it select a multiple choice answer option for ONLY question: QID1215751872. The issue is that the below input jQuery works, but it then fills all questions on the page with answer code 1.

I just want to target that one QID. The bottom two jQuery's seem to not work. How can I target one QID and select a certain choice id?
 

Qualtrics.SurveyEngine.addOnload(function () {
    var PullEmbData = Qualtrics.SurveyEngine.getEmbeddedData('Filter1');
    console.log("Answer is:" + PullEmbData)
    

    if (PullEmbData = 'PulledValue') {
        jQuery('inputchoiceid=1]').prop('checked',true);
    };
    
    //jQuery('#' + this.questionId + 'input+choiceid=1]').prop('checked',true); 
    //jQuery('#QID1215751872 input/choiceid="1"]').prop('checked', true)

});

Many thanks!

Try this:

Qualtrics.SurveyEngine.addOnload(function () {
var PullEmbData = Qualtrics.SurveyEngine.getEmbeddedData('Filter1');
console.log("Answer is:" + PullEmbData)


if (PullEmbData = 'PulledValue') {
jQuery(this.getQuestionContainer()).find('input[choiceid=1]').prop('checked',true);
};

});

 


Legend! That works, many thanks! :)


Leave a Reply