Solved
Is there a way to record which random number was generated by the random integer command?
I have a survey where I am generating a random number between 1 and 6 (${rand://int/1:6}) in loop and merge and piping it from loop and merge into the text of a question. I want to record what random number was was presented in each of the loops. Right now I have JS code that is saving the piped text from the loop and merge into an embedded data field, but it looks like it is saving a new random number to the embedded data field and not the number that was presented.
Does anyone know if there is a way to record the actual number that was shown/generated, rather than a new random number?
Best answer by TomG
@mcoverdale - You're saying the value of the piped field (e.g. $lm://Field/2) changes in the same loop? That doesn't sound right.
Anyway, an approach that will guarantee that you save the same number presented...
Put your piped random number inside a span with an id:
```
<span id="myRandNum">${lm://Field/2}</span>
```
Then have your JS save the contents of your span to an embedded data field:
```
Qualtrics.SurveyEngine.setEmbeddedData(${lm://CurrentLoopNumber}+"_myRandNum",jQuery("#myRandNum").text());
```
Be sure to initialize your embedded data fields (e.g., 1_myRandNum, etc.) in the survey flow.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

Thanks for the suggestion though!