How to hide multiple choice buttons? | XM Community
Skip to main content
Solved

How to hide multiple choice buttons?

  • January 27, 2021
  • 6 replies
  • 267 views

Hello all,
How can I hide the multiple choice buttons for my questions? I have added some JS code so participants can respond using key presses so I don't want participants to answer by mouse-clicking on the buttons on the screen.
I have tried variations of the following code but haven't been able to make it work - could someone kindly help me with this?
Many thanks in advance!

Qualtrics.SurveyEngine.addOnload(function()
{
this.hideNextButton();
this.hidePreviousButton();
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) {
var choiceID = null;
switch (e.keyCode) {
case 74: // 'j' was pressed
choiceID = 1;
break;
case 75: // 'k' was pressed
choiceID = 2;
break;
}
if (choiceID) {
Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
that.clickNextButton();
var v = document.getElementsByClassName('MultipleAnswer');
for (i = 0; i < v.length; i++) { 
v[i].style.visibility = "hidden";
}
}
});
});

Best answer by ahmedA

So your problem is simple. Because you are adding the images to the question, you just need to hide the choices. Add this line to the JS:

this.getChoiceContainer().hide()
and you should get what you are aiming for.

6 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • January 27, 2021

What's your theme?


  • Author
  • January 27, 2021

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • January 27, 2021

That's a custom theme, so I have no idea how its been setup. Could you share a link of the question? As you can see from this discussion and this one, that different configs require different options. Also, sometimes things may not work out due to the themes.


  • Author
  • January 27, 2021

https://www.qualtrics.com/community/discussion/comment/33850#Comment_33850Thank you for your response ahmedA, I appreciate your help! I have created a test survey for you to look at: https://uclpsych.eu.qualtrics.com/jfe/form/SV_0VPu85vvgHJEQaq
Edit: Sorry the first post of the link didn't quite work for some reason. This one works.


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Answer
  • January 28, 2021

So your problem is simple. Because you are adding the images to the question, you just need to hide the choices. Add this line to the JS:

this.getChoiceContainer().hide()
and you should get what you are aiming for.


  • Author
  • January 28, 2021

Edit: It worked! Thank you so much ahmedA