JavaScript to clear text entry boxes? | XM Community
Skip to main content

Hello everyone! Thank you for checking out my post.
I have an experiment where participants fill out text entry boxes in one round, then repeat (using the same questions, duplicated in the survey flow). Unfortunately, this doesn't really work at the moment as the answers they put in the first round are already present in the text boxes in the second round.
Is there some custom code that can prevent the responses from before being remembered by Qualtrics/the browser, so the boxes are always empty?
Thank you very much for your time!

Hi oakiel ,

the javaScript would be:

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
let copiedText = document.getElementById('QR~'+this.questionId).value //stores the text

Qualtrics.SurveyEngine.setEmbeddedData("ebdOpenText", copiedText); //writes the stored text into an embedded data field

document.getElementById('QR~'+this.questionId).value = ""; //clears the text entry box




});

However, I am not sure that repeating the block in the survey flow is the best of all options.
If you have questions to be asked twice or x-times you might rather go for a loop&merge block

Best regards

Rudi


Leave a Reply