how can i disable Submit Button if answer is "No"

RahulRahul GurgaonCommunity Member Qubie ✭

how can i disable Submit Button if answer is "No"

Looking for guidance to disable Submit Button if answer is "No" in single select select question with Yes/No choices.

Example:
Are you sure you want to submit the survey?
1. Yes
2. 2. No

If answer is yes then submit button is enables and if answer is No then submit button is disabled

Best Answers

  • JenCXJenCX Broomfield, CO Superuser ✭✭✭✭
    Accepted Answer

    What should happen if they hit no?

    I would use branching logic to either send them to the end of the survey (if yes) or send them back to wherever they should go if no.

  • jainshubhamjainshubham Mumbai Guru ✭✭
    edited May 29 Accepted Answer

    Hi @Rahul,

    If you want to accomplish this feat using JS, below is the code you can use. You would need to replace the button ID (NextButton) & option ID's (QID1-1-label, QID1-2-label) with your survey's relevant id's that you can find by inspecting the elements.

    Qualtrics.SurveyEngine.addOnReady(function()
    {
        document.getElementById('QID1-1-label').onclick = function(){
            document.getElementById("NextButton").disabled = false;
    }
        document.getElementById('QID1-2-label').onclick = function(){
            document.getElementById("NextButton").disabled = true;  
        }
    });
    
  • TomGTomG Raleigh, NC Wizard ✭✭✭✭✭
    Accepted Answer
    Qualtrics.SurveyEngine.addOnload(function() {
        var qobj = this;
        jQuery("#"+this.questionId+" input[type=radio]:first").click(function() { qobj.enableNextButton(); }); //Yes
        jQuery("#"+this.questionId+" input[type=radio]:last").click(function() { qobj.disableNextButton(); }); //No
    });
    

Answers

  • RahulRahul GurgaonCommunity Member Qubie ✭

    If they hit no they should go back and answer unanswered questions

  • RahulRahul GurgaonCommunity Member Qubie ✭

    thank you Tom, Shubham, @jpardicusick.
    I will try out these options and let you know if it worked

Sign In to Comment