Context: My survey consists of one multiple choice question. I am trying to make it so that the next button is disabled if none of the options are selected.
I have attempted to implement this by calling disableNextButton() and setting a questionclick function within addOnload.Qualtrics.SurveyEngine.addOnload(function()
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
this.disableNextButton();
this.questionclick = function(event,element) {
if (this.getSelectedChoices().length > 0) {
this.enableNextButton();
} else {
this.disableNextButton();
}
};
});
What keeps happening is the following:
- On survey load, the button will momentarily be disabled, but then will re-enable
- If I click anywhere within the question container (NOT ON AN OPTION), it disables
- When I click on an option, the next button becomes enabled
- If I then deselect that option, the next button doesn't become disabled until I click somewhere outside the selections (as in step 2)
When I inspected the Qualtrics javascript, I have noticed that upon page load and selecting/de-selecting any option, there's a series of functions that are called that ends up re-enabling the next button:
unbusify calls loadEnd which then re-enables the next button. This happens *every* time the form is loaded and a selection is changed, which basically makes my disabling of the button futile. loadEnd is only called AFTER my click handler and addOnload/addOnReady so it basically consistently undos any setting I do (unless I'm clicking within the question container and not a selection.
Is there some setting or way to get loadEnd to stop consistently re-enabling the button?
I have also tried the following:
- Using document.getElementById('NextButton').disabled to disable the button
- using addOnReady instead of addOnLoad