Hi all,
My survey uses a different person's name for each question, and I want them randomized from a list
For example, for Q1 I would pipe in "name1", for Q2 I would pipe in "name2"... so I want to create variables name1 to name30.
I put the following code in the js of an introductory page of my survey that doesn't use a name. I create an array, shuffle the order, then assign values to the new field names.
But even after this page, the names don't show up. Can someone tell me if/where I've done something wrong?
Qualtrics.SurveyEngine.addOnload(function()
{
let names = ["Jennifer", "Jessica", "Amanda", "Ashley", "Sarah", "Stephanie", "Melissa", "Nicole", "Elizabeth",
"Heather", "Tiffany", "Michelle", "Amber", "Megan", "Amy", "Rachel", "Kimberly", "Christina",
"Lauren", "Crystal", "Michael", "Chris", "Matt", "Josh", "David", "James", "Daniel",
"Robert", "John", "Joe", "Jason", "Justin", "Andrew", "Ryan", "William", "Brian", "Brandon", "Jon",
"Nick", "Tony", "Eric", "Adam", "Kevin", "Tom", "Steve", "Tim", "Richard", "Jeremy", "Jeff", "Kyle"];
shuffle(names);
for (let i = 0; i < names.length; i++) {
Qualtrics.SurveyEngine.addEmbeddedData("name"+i, names[i]);
}
});
Best answer by SurajK
View original