Would the easiest way to do this be "PUT" string length to Embedded Data "Comment Length" then use Branch logic to check if "Comment Length" is greater than/equal to 300?
Thanks a lot !
Qualtrics.SurveyEngine.addOnReady(function()
{
var questionID = this.questionId;
var textbox =$('QR~' + questionID);
var that = this;
function countWords(s){
s = s.replace(/\\n/g,' '); // newlines to space
s = s.replace(/(^\\s*)|(\\s*$)/gi,''); // remove spaces from start + end
s = s.replace(/[ ]{2,}/gi,' '); // 2 or more spaces to 1
if(s == ''){
return 0;
}else{
return s.split(' ').length;
}
}
textbox.onkeyup = function(e){
var aa = countWords(textbox.value);
console.log(textbox.value);
Qualtrics.SurveyEngine.setEmbeddedData("ED1", aa);
}
});
From what I understand, as I'm new to this, is you need to update the last part of the script . "aa" needs to unique to each open-end question as well as "ED1" which is the name of your new embedded data in your dataset.
Once this is done, you need to map your embedded data in your survey flow (Add embedded data and type the name of your ED variable - make sure it is in number format).
Happy to help further if needed.
Good luck !
Hi @emilyvoc , here's the Java Script I added to my open-end question:
Qualtrics.SurveyEngine.addOnReady(function()
{
var questionID = this.questionId;
var textbox =$('QR~' + questionID);
var that = this;
function countWords(s){
s = s.replace(/\\n/g,' '); // newlines to space
s = s.replace(/(^\\s*)|(\\s*$)/gi,''); // remove spaces from start + end
s = s.replace(/[ ]{2,}/gi,' '); // 2 or more spaces to 1
if(s == ''){
return 0;
}else{
return s.split(' ').length;
}
}
textbox.onkeyup = function(e){
var aa = countWords(textbox.value);
console.log(textbox.value);
Qualtrics.SurveyEngine.setEmbeddedData("ED1", aa);
}
});
From what I understand, as I'm new to this, is you need to update the last part of the script . "aa" needs to unique to each open-end question as well as "ED1" which is the name of your new embedded data in your dataset.
Once this is done, you need to map your embedded data in your survey flow (Add embedded data and type the name of your ED variable - make sure it is in number format).
Happy to help further if needed.
Good luck !
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.