How to disable/enable Next Button from Header (from Look & Feel)? | XM Community
Skip to main content

I have a function that detects any changes in the user's window and when a certain width/height is reached, I want to alert the user and disable the next button.
What I am trying to achieve is something along the lines of:

if (condition == True) {

disableNextButton()

} else {

enableNextButton()

}

This needs to go in the Header, under Look & Feel as this is a function that will apply on all pages of my survey.
This sort of code work perfectly when I put it in individual questions as I can use the
this
object as follows:
if (condition == True) {

this.disableNextButton()

} else {

this.enableNextButton()

}

However, I can't seem to find an alternative for applying that in the Header and workarounds seem quite cumbersome.
Any ideas?

If in the header you use the below function then we can use this keyword:
Qualtrics.SurveyEngine.addOnReady(function(){
this.disableNextButton();
});


Brilliant, thanks rondev !
For future sillies like me this might also help:
When you have a function inside the

Qualtrics.SurveyEngine.addOnReady
function, make sure to save the
this
object into a new variable (traditionally
that
) so that you can use it inside other functions:
Qualtrics.SurveyEngine.addOnReady(function() {

that = this

function myfunc() {

if (condition == True) {

that.disableNextButton()

} else {

that.enableNextButton()

}

}

});


Leave a Reply