How do I hide next button for specific questions on same page? Show when answer is selected only | XM Community
Question

How do I hide next button for specific questions on same page? Show when answer is selected only

  • 29 June 2020
  • 5 replies
  • 28 views

Hello,
I found code to hide the next button for the entire page but I need to hide the next button on specific questions that are on the same page and ONLY display the next button when user selects a specific answer choice (A,B,C, or D).
For example, if user selects "yes this answered my question", then no next button, but if user selects "I need to open a case" I need the next button to appear so they can advance to the next page and submit a case.
Thanks so much!!


5 replies

Userlevel 7
Badge +22

You can try the below code: The below code is for single choice with two options, like if option2 is selected then next button is enabled else kept disabled.
Paste the below code in the JS onReady function.
this.disableNextButton();
//question click is a simple onclick handler
//attached to the question's container div
this.questionclick = function(event,element)
{
//by default you get the click event as the first parameter and the clicked element as the second parameter
console.log(event, element);
if (element.type == 'radio')
{
var choiceNum = element.id.split('~')[2];
//alert('You clicked on choice '+choiceNum);
if (choiceNum == 2)
{
//enables the next button - Note that the QuestionData object is bound to this to make it easier to use
this.enableNextButton();
}
else
{
//disables the next button
this.disableNextButton();
}
}
}

Userlevel 5
Badge +4

Same discussion here,
https://www.qualtrics.com/community/discussion/comment/27071#Comment_27071

Thank you both! If it is a single questions with 4 choices and option 4 is selected would I just change both 2's to 4's in the above code like below:
var choiceNum = element.id.split('~')[4];
//alert('You clicked on choice '+choiceNum);
if (choiceNum == 4)

Userlevel 7
Badge +22

https://www.qualtrics.com/community/discussion/comment/27379#Comment_27379No, change only the 2 in the if statement

I have the code below in my survey to hide next button throughout entire survey but when I add code above to a question it does not trigger the next button to appear...did the code override one another?


Leave a Reply