How to hide multiple choice buttons? | XM Community
Solved

How to hide multiple choice buttons?

  • 27 January 2021
  • 6 replies
  • 100 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";
}
}
});
});

icon

Best answer by ahmedA 28 January 2021, 01:19

View original

6 replies

Userlevel 7
Badge +21

What's your theme?

https://www.qualtrics.com/community/discussion/comment/33846#Comment_33846I'm using the University College London theme.
Picture1.png

Userlevel 7
Badge +21

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.

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.

Userlevel 7
Badge +21

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.

Edit: It worked! Thank you so much ahmedA

Leave a Reply