How can I hide the next button in a block until two multiple choice questions are answered? | XM Community
Skip to main content

An image and two multiple choice questions are shown on the screen. After 7 seconds the image disappears but subjects have an unlimited time to answer the two multiple choice questions. These questions are both forced choice, however, if you click on the next button the image is then re-shown and disappears again following 7 seconds. To prevent this issue, I would like to disable the next button until both multiple choice questions have been answered.
I have this code for the 7 seconds and disabling the next button but I do not know how to reference both questions
Qualtrics.SurveyEngine.addOnload(function()
{
var img = jQuery("#"+this.questionId+" img");
setTimeout(function() { img.hide(); },7000);

this.disableNextButton();

this.questionclick = function(event,element)
{
if (element.type == 'radio')
{
this.enableNextButton();

});
Any help would be massively appreciated!!
Thank you!!😀

Try this:
Qualtrics.SurveyEngine.addOnload(function() {
var img = jQuery("#"+this.questionId+" img");
var qobj = this, radios = jQuery("[type=radio]");
if(radios.filter(":checked").length < 2) {
qobj.disableNextButton();
setTimeout(function() { img.hide(); },7000);
}
radios.click(function() {
if(radios.filter(":checked").length == 2) qobj.enableNextButton();
});
});


Leave a Reply