How do I make previous buttons disappear on selected questions? | XM Community
Skip to main content
I am trying to have the previous button not show up on selected questions. I have tried two custom java scripts (see below), but if the question is answered incorrectly on the page with the java script (i.e. the error message appears), the previous button reappears and you can go back.



I am aware of the solution of dividing it into blocks and using branches, however the survey is quite extensive and this would require 50+ additional blocks and branches in an already complicated flow. The other option is of course to remove them completely but this makes other parts of the survey difficult.



Is there a way to do this with custom script so that the previous button stays hidden even when the question is answered incorrectly?



Java Scripts I tried (when loading, when displayed, when unloading):



$('PreviousButton').hide();

$('PreviousButton').disable();



OR



{

$('PreviousButton').hide();

});
What function are you running that code from? Try this:

```

Qualtrics.SurveyEngine.addOnReady(function() {

jQuery("#PreviousButton").hide();

});

```
Hello @ASFriesacher ,



Paste the below code in the js(onReady) of the question



if(jQuery(".ValidationError").text()==""){

jQuery("#PreviousButton").hide();

}else{

jQuery("#PreviousButton").css("visibility","collapse");

}
Thank you Shashi, this works perfectly.



Tom, unfortunately the same thing happens as I described above with the code you suggested, but thank you anyway!
This appears to be a timing issue introduced by a recent Qualtrics change (I also notice that hiding Separators in the addOnload function no longer works either due to a timing issue). Deferring the PreviousButton hide until the stack clears works:

```

Qualtrics.SurveyEngine.addOnReady(function() {

setTimeout(function() { jQuery("#PreviousButton").hide(); },0);

});

```

Leave a Reply