Javascript Responses not Displayed in Exported Data | XM Community
Skip to main content
Hi everyone,

I am not java savy, and this is also my first time using Qualtrics. I have a question that displays a picture and participants press "1" or "2" for unpleasant and pleasant respectively. Their responses (which number they press) do not appear in the exported data such as spss or excel. How do it get it to show up? What do I need to add to my code and what do I do in my survey flow?

Here is my code:

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 49: // '1' was pressed

choiceID = 1;

break;

case 50: // '2' was pressed

choiceID = 2;

break;

}

if (choiceID) {

that.setChoiceValue(choiceID, true);

that.clickNextButton();

}

});



});



Qualtrics.SurveyEngine.addOnReady(function()

{



});



Qualtrics.SurveyEngine.addOnUnload(function()

{



});



Thank you,



Stressed First-Timer
1. The JavaScript has to be attached to a multiple choice question

2. The multiple choice choices have to have the choice ids 1 and 2



If those two conditions are met, the data will the answer to the multiple choice question in your response data.
The picture stands alone as a graphic. There is no multiple choice question attached to it. This is done so as to keep the response time as accurate as possible. Is there any way that I can still record whether the participant pressed the "1" or "2" button to advance to the next page?
> @psych123 said:

> The picture stands alone as a graphic. There is no multiple choice question attached to it. This is done so as to keep the response time as accurate as possible. Is there any way that I can still record whether the participant pressed the "1" or "2" button to advance to the next page?



It would be easier to change it to a MC with two choices and add this line to the beginning of your JS:

```

jQuery(".QuestionBody").hide();

```

Leave a Reply