how can i disable Submit Button if answer is "No" | XM Community
Skip to main content
Solved

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

  • May 29, 2019
  • 5 replies
  • 417 views

Forum|alt.badge.img+1
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 answer by jainshubham

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

5 replies

JenCX
Level 5 ●●●●●
Forum|alt.badge.img+11
  • Level 5 ●●●●●
  • May 29, 2019
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.

Forum|alt.badge.img+1
  • Author
  • May 29, 2019
If they hit no they should go back and answer unanswered questions

jainshubham
QPN Level 2 ●●
Forum|alt.badge.img+3
  • QPN Level 2 ●●
  • Answer
  • May 29, 2019
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; } });

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • May 29, 2019
``` 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 }); ```

Forum|alt.badge.img+1
  • Author
  • May 29, 2019
thank you Tom, Shubham, @jpardicusick. I will try out these options and let you know if it worked