Solved
How do I customize carry forward statements?
Hello! I am trying to customize some carry forward statements. I have a constant sum question and I want to carry forward the top 5 statements by inputted numerical value from that into my next question. Does anyone know how to do this?
Best answer by Ansh_Par
Figured it out: Here is the syntax for anyone that needs it:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type) {
var $jq = jQuery.noConflict();
var answers = $jq('.Selection input').map(function(val) {
return $(this).getValue();
});
var questions = $jq('.Selection label span').map(function(val) {
return $(this).innerHTML;
});
zip = []
for(var i = 0; i < answers.length; i++) {
zip.push([parseInt(answers[i]), questions[i]]);
}
zip.sort(function(a, b) {
return b[0] - a[0];
});
top_5 = zip.slice(0, 5).map(function(val) { return val[1]});
console.log(top_5);
Qualtrics.SurveyEngine.setEmbeddedData('top_5_questions', top_5);
Just make sure you create a 'top_5_questions' variable in survey flow in order for this to work with embedded data.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

