Hi,
I need my participants to press keys on the keyboard to answer the questions. I'm using multiple choice questions with keyboard responses (using javascript). Now I just need to hide the multiple choice buttons. Here's a screenshot of where I am:
!
I'd like to hide those two buttons.
The javascript code I used for keyboard response is:
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 80: // 'p' was pressed
choiceID = 1;
break;
case 78: // 'n' was pressed
choiceID = 2;
break;
}
if (choiceID) {
Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
that.clickNextButton();
}
});
Page 1 / 1
Hi,
here is the complete code that you need to put in JS editor, refer last three lines of code to hide the buttons.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
this.hidePreviousButton();
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) {
var choiceID = null;
switch (e.keyCode) {
case 80: // 'p' was pressed
choiceID = 1;
break;
case 78: // 'n' 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";
}
});
here is the complete code that you need to put in JS editor, refer last three lines of code to hide the buttons.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
this.hidePreviousButton();
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) {
var choiceID = null;
switch (e.keyCode) {
case 80: // 'p' was pressed
choiceID = 1;
break;
case 78: // 'n' 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";
}
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.