How to show the NextButton when a certain chioce is selected

DylanDylan Hong KongCommunity Member Qubie ✭
edited May 12 in Qualtrics API

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(); });

});

Tagged:

Best Answer

  • rondevrondev Community Member - Trial User Wizard ✭✭✭✭✭
    Accepted Answer

    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(); });
    


Answers

  • DylanDylan Hong KongCommunity Member Qubie ✭

    Wow, Rondev, it works! Many thanks!

Sign In to Comment