I have a embedded variable that I append information to (so I can track stuff within a loop and merge) each trial. The problem is, when force response is triggered (the subject doesn't respond to a question), it "reloads" the page, and triggers all the Javascript to run. If I have a code block in addOnUnload (or anywhere, really) that takes an embedded variable and appends something to it, it will append something twice for that trial.
Is there any way to avoid this? I.e. some function/event listener that will ONLY trigger when the survey advances to the next page?
Minimum reprex: Create an embedded variable testvar. Create a question with force response. Add javascript to the unload block for that question that sets testvar to testvar + "," + Math.random(). Run the survey, do not answer the question, and keep trying to click next. This will keep appending a new random number to testvar. Instead, I want this to happen only when the survey advances successfully.
Page 1 / 1
Can you check if there is any text entered in the field before append information to the embedded variable. If the text field is empty, then don't trigger the append function.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.