only accept first MCQ answer (without moving page) | XM Community
Skip to main content

Hi, 

 

I have a MCQ and I need to only accept the first answer to the question. However, I also need the participant to stay on the same page. Is this possible? e.g. disable the question after selection?

 

Any help/advice would be great, 

 

Thanks, 

if it’s first choice add the below code onLoad

jQuery(‘inputntype=”checkbox”]’).eq(0).prop(‘checked’,true)

 


Hi Rahul, 

 

Thanks for taking the time to reply to my question, however this doesn’t seem to work. The code is accepted but when I run the survey, I am able to change the selection of the MCQ. 

 

Mark


Hey @markw,
Please try the below code.
 

Qualtrics.SurveyEngine.addOnload(function() {
    var questionId = 'QID'; // Replace 'QID' with the actual question ID
    var selected = false;

    // Add a change event listener to the question's inputs
    jQuery('#'+questionId+' input').on('change', function() {
        if (!selected) {
            selected = true;
            jQuery('#'+questionId+' input:not(:checked)').prop('disabled', true);
        }
    });
});


Leave a Reply