[Solved] Script to hide “Next” button until required question AND required answer is selected

0

I’m trying to build a script that hides the next button if 1) a single-select question is present, and 2) the question is answered a certain way.

To give it some context, I am asking some respondents (not all, though) “Are you done?”. If the question is there, I want them to answer “Yes” before going to the next page. If they answer “No”, I want the “Next” button to be hidden until they answer “Yes”.

So essentially, I not only want to require a question (if the question is present), but I want to require an answer as well.

Help?

Nick Wicks selected answer

    Best answer

    0

    Hey Dominic, thanks for the help. We ended up figuring out a good way to do it using client-side JS:

    var addListeners = function(){
    $(“#sgE-[dev ID number of radio button you want to hide from]”).on(“change”, function(e){
    $(“#sg_NextButton”).hide();
    });
    $(“#sgE-[dev ID number of radio button you want to show from] “).on(“change”, function(e){
    $(“#sg_NextButton”).show();
    });
    };

    if( $.isReady ) { addListeners() } else { $(addListeners); }

    Thanks again, though.

    Dominic Sharpe commented
      0

      You might start with something like this:

      $SG(document).ready(function(){
      $SG(“#sg_NextButton”).hide();
      $SG(“# id of button that is clicked to show Next”).click(function(){
      $SG(“#sg_NextButton”).show();
      $SG(“# id of button that is clicked to hide Next”).click(function(){
      $SG(“#sg_NextButton”).hide();
      });
      });
      });

      There is probably a more efficient way of doing this (I’m no developer). Also, missing here is the if statement for evaluating if the question is on the page, but hopefully it’s at least somewhat helpful!

      Cheers!

      Dominic Sharpe answered
        ×

        Login

        Question stats

        • Active
        • Views2587 times
        • Answers2 answers
        • Followers1 follower