Text box has disappeared from item (using JavaScript) | XM Community
Solved

Text box has disappeared from item (using JavaScript)

  • 26 July 2018
  • 1 reply
  • 27 views

An issue has arisen in a number of my surveys that use QRT Engine to capture response times (they’re old surveys but I’m midway through a study so I can’t change the design). The issue is that the text box in the image below does not load for this item of the survey. As a result, participants are unable to enter a rating. The javascript for this item is pasted below the image.

Thanks in advance

!



QRTE.Stimulus ({
id: 'Ind_Confidence', //Should be a unique ID, per stimulus in a trial block
onShowFn: function() {
$('Plug').style.display = 'None';

var id = 'confidenceText';
field = document.getElementById(id);

field.style.display = 'inline';
field.focus();
field.select();

function check(rating) {
if (rating && rating >= 0 && rating <= 100) {
return true
} else {
alert ('Please type a number between 0 and 100.')
return false
}
}

// Proceed on 'Enter' key press
field.onkeyup = function(e){
if(e.keyCode == 13 || e.keyCode == 13){
var rating = field.value;
if (check(rating)) {
e.preventDefault();
QRTE.proceed();
return (false)
}
}
}
},

// Save individual confidence rating at end.
onHideFn: function(ele, ts) {
var rating = field.value;
QRTE.setTrialData(ele.userId + '[resp]', rating);
}
});
icon

Best answer by TomG 26 July 2018, 15:49

View original

1 reply

Userlevel 7
Badge +27
The JavaScript you've shown assumes that the text box is already there (and has an id of 'Ind_Confidence'). So, I don't know if you need to have a text entry question for it (in which case the id would be a Qualtrics question id) or some other part of the QTRE code is supposed to add it. My guess would be the latter since it looks like setTrialDate is maybe saving it to an embedded variable.

Leave a Reply