Hide Next button and Auto-advance on Click & Sudden error. | XM Community
Skip to main content
Hello all.



I am trying to accomplish 2 fairly straightforward tasks that I can do individually, but I am having problems combining the logic.



Goal: To hide the Next button on a specific page AND have the page auto-advance when an answer is clicked (radio button).

Background: The page contains 3 questions. 1 question will always show (radio button question), but only 1 of the remaining 2 questions (descriptive text) will show depending on display logic. I also use display logic to hide an answer choice, but that shouldn't cause any issues.



This is the code I am using on my radio button question (which is the first question on the page).



Qualtrics.SurveyEngine.addOnload(function()

{

var that = this;

this.questionclick = function(event,element){

if (element.type == 'radio') {

that.clickNextButton();

}

}



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



});





New issue! I recently tested the top section of the code that is used to auto-advance on click, a the survey I am editing and I am getting the following error.



!



I am connected to the internet and the same code works perfectly fine in a different survey I've created. Any ideas brilliant minds?
My first question, why are you creating the 'that' var? I could be wrong, but it doesn't look necessary. Even though JS should create an exact copy of the same data type, maybe it isn't. Perhaps there are some private non-inheritable traits that are not getting assigned to the new var and it is causing the connection with the API to time out.
@rsuter - Good question! And I have no idea, lol. I'd love to learn more, but basically have 0 coding skills (outside of some HTML and CSS). I want to learn more, but hasn't been a priority with my work.



The code you see is stuff I have scraped from other forum discussions.. If you have a better way to write this, I am very open to suggestions.
@Akdashboard

I just tried this and it worked. Hid the button and moved to next page.



Qualtrics.SurveyEngine.addOnload(function()

{

this.hideNextButton();

this.questionclick = function(event,element){

if (element.type == 'radio') {

this.clickNextButton();

}

}



});



And if you are interested in learning more about the methods(functions) available for the Qualtrics JS Question API, you can find them all listed here: https://amazonuni.au1.qualtrics.com/WRAPI/QuestionAPI/classes/Qualtrics%20JavaScript%20Question%20API.html#method_hideNextButton



The documentation around parameters and examples should be helpful in getting a base understanding. I would also avoid JQuery unless you're 100% sure that it works. I'm not well versed in the differences, but since the official documentation is written for JS, I would just stick with that.

Leave a Reply