Hi all,
I am struggling with my javascript code, it seems to run fine but when I download the data the embedded data field (in this case 'P1' is empty). I would like the code to record a 'F' key press as 1 and 'J' key press as 2 and then record the RT before submitting the page. I tested it using Qualtrics.SurveyEngine.setEmbeddedData('P1', 'testing') and it records the string but not when I try to record the RT variable.
Qualtrics.SurveyEngine.addOnload(function() {
var starttime = new Date().getTime
this.hideNextButton()
var qobj = this;
jQuery(document).keypress(function(event){
var key = event.key.toUpperCase();
if(key == "J" || key == "F") {
jQuery(this).trigger("mouseup");
var endtime = new Date().getTime();
var RT = (endtime - starttime)/1000;
if (key == "F"){
qobj.setChoiceValueByRecodeValue(1,true);
} else {
qobj.setChoiceValueByRecodeValue(2,true);
}
Qualtrics.SurveyEngine.setEmbeddedData('P1', RT);
$('NextButton').click();
}
})
});
Any help is much appreciated!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.