How to show the NextButton when a certain chioce is selected | XM Community
Solved

How to show the NextButton when a certain chioce is selected


Hi everyone,
I came into a problem, very simple: A multiple choice question with two choices: A and B. When this question is displayed at the beginning (both choices are unselected), I want the NextButton to be hided, which is realized by the code "  $('NextButton').hide();". Furthermore, when choice A is selected, I would like the NextButton to be shown, while when choice B is selected, I would like the NextButton to stay hided.
Enclosed below is my drafted code, which can only realize hiding at the begining. Can anyone shown me what should I write for the whole functions? Really appreciate that! I have little coding experience so please feel free to help me out without hesitation!


Qualtrics.SurveyEngine.addOnReady(function()
{
  $('NextButton').hide();
var qobj = this;
jQuery("#"+this.questionId+" input[choiceid=1]").click(function() { qobj.showNextButton(); });
});

icon

Best answer by rondev 12 May 2020, 10:04

View original

2 replies

Userlevel 7
Badge +22

Use below code:
var next = jQuery("#NextButton");
   next.hide();
  jQuery("#"+this.questionId+" input[type=radio]:eq(0)").click(function() { next.show(); });
  jQuery("#"+this.questionId+" input[type=radio]:eq(1)").click(function() { next.hide(); });

Wow, Rondev, it works! Many thanks!

Leave a Reply