Target one multiple choice question and select radio button via jQuery | XM Community
Solved

Target one multiple choice question and select radio button via jQuery

  • 13 June 2024
  • 2 replies
  • 26 views

Badge +1

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('input[choiceid=1]').prop('checked',true);
    };
    
    //jQuery('#' + this.questionId + 'input[choiceid=1]').prop('checked',true); 
    //jQuery('#QID1215751872 input[choiceid="1"]').prop('checked', true)

});

Many thanks!

icon

Best answer by TomG 13 June 2024, 15:09

View original

2 replies

Userlevel 7
Badge +27

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);
};

});

 

Badge +1

Legend! That works, many thanks! :)

Leave a Reply