Output in Qualtrics Survey is the same after using a javascript mask | XM Community
Skip to main content

Hi all,
I'm running into an issue where it appears input entered into a survey in an earlier question is being overwritten, and my output is showing up as the same value even though different values were entered into the survey.
Here is example javascript added to two different survey questions:
Question 1 (under edit question Javascript):
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/

var Fbd1 = "input[id='QR~"+this.questionId+"']";

jQuery("#" + this.questionId + " .InputText").hide();

jQuery("#appt-time").on(" change", function() {

jQuery(Fbd1).val(jQuery("#appt-time").val()) ;

});

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/

});
Question 2 (under edit question Javascript):
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/

var Fbd2 = "input[id='QR~"+this.questionId+"']";

jQuery("#" + this.questionId + " .InputText").hide();

jQuery("#appt-time").on(" change", function() {

jQuery(Fbd2).val(jQuery("#appt-time").val()) ;

});

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/

});
The first question is "What was your bedtime?"
The second question is "What was your wake time?"

I have noticed whatever is entered into the second question seems to be overwriting the output for the first question. For example, if I respond 8:00PM for the first question and 4:00AM for the second question, in the output both answers are showing up as 8:00PM.
I am not great with Javascript and I am thinking this has something to do with the custom javascript code that I have added. Any and all input would be greatly appreciated.

Thank you.


I'm not a Javascript expert so I can't say if that is the issue here, but this seems similar to something I experienced a year ago. Did you write your own HTML in any questions? The problem I had was with a missing or extra

container; it seemed to offset the responses in the fields that followed, and repeated the same numeric entry in many of them. The problem could be due to Javascript but I would suggest ruling out this HTML glitch too.


Hi Matthew,
Thanks for your quick response. I am using a Javascript date picker in a previous question... I am still investigating whether this could be causing the issue. I would not have thought to do this an I appreciate your insight here.


@MatthewM,
I ended up getting it sorted out. It had to do with the Javascript and not the HTML, but I just would like to thank you again for reaching out so quickly to try to help!
Cheers,
Sean


Leave a Reply