```
var str = "${m://Email1}";
var substrings = str.split("@",2);
console.log (str);
console.log (substrings.length);
console.log (substrings[0]);
console.log (substrings[1]);
Qualtrics.SurveyEngine.setEmbeddedData(\\"userID\\",substrings[0]);
```
The code runs and does what I expect expect I can not get it to change the value of the "userID" field if I add the code to the same block where the variable is used. I have tried to put it in the Qualtrics.SurveyEngine.addOnload and I see it execute in the console log but the value displayed in the question is not the value passed in by the JS code. The only way I can get it to work properly is to load the code on a prior block in the survey.
Questions:
Is there an easier way to parse this string inside the survey with using the JS?
Am I doing something wrong in placing this code to make it execute before the page displays?
Is there a place I can look for a middle level primer on the Qualtrics / JS interaction. Everything I have seen is either very basic or very advanced.
Many Thanks!!
Best answer by TomG
View original