Hide All Radio Buttons with Custom Code | XM Community
Skip to main content

Hi everyone. I just want to preface this by saying I am a student and I have no previous experience with JavaScript.
For my survey I am currently using this code to register key presses as radio button clicks and auto-advance to the next question.
Qualtrics.SurveyEngine.addOnload(function()
{
var qobj = this;
  jQuery(document).keypress(function(event) {
    var key = event.key.toUpperCase();
    if(key == "J" || key == "F") {
      jQuery(this).trigger ("click");
      if(key == "J") qobj.setChoiceValueByRecodeValue(1,true);
      if(key == "F") qobj.setChoiceValueByRecodeValue(2,true);
document.getElementById("NextButton").click(); 
    }
  });
});

My question is: now that participants can select options using key clicks what code could I use to hide the radio buttons so the whole survey looks more clean.

Just add this line to your JS:
this
.getQuestionContainer()
.querySelectorAll("[class^='q-']")
.forEach(button => button.hide());


Hi Ahmed,
Thanks so much for the code! I played around with it a bit and it ended up working :)


Leave a Reply