Javascript code to hide a question is auto-advancing the Response Summary | XM Community
Skip to main content

Hello,

I have a Custom End of Survey element to show a response summary, and I checked the box “Show Response Summary before completing the survey” because we would like respondents to have the opportunity to review their responses before submitting them. Unfortunately, the response summary is auto-forwarding and submitting the survey responses after appearing for just a couple seconds.

I reached out to Qualtrics Support for an explanation, and their tech team said that this is occurring because of custom JavaScript code that I was using to hide a question on the survey. Specifically, they said the code to automatically click the “next” button on the hidden question was somehow also clicking the “next” button when the response summary appeared (though it’s a mystery to me as to why that would happen). They said that removing that JavaScript code should resolve the issue, but I need it to hide a form question that is saving question response values to be used as the key in a subsequent Loop & Merge block (more on that below).

 

Here is the JavaScript code that I am using to hide a single question:

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

jQuery('#'+this.questionId).hide();
this.clickNextButton();
});

So, my first question is: Is there a way to use JavaScript to hide this question without the Response Summary auto-forwarding? Perhaps by referencing the specific Question ID rather than using “this.questionId”? Note that I can’t hide the question using display logic in the survey, since I need the form field response values to be saved for use as the key in a Loop & Merge block. And I don’t want to display the question because I don’t want respondents to be able to edit the form field responses (I am using default choices to set these fields to equal embedded data values that were passed in via the URL query string).

If that’s not possible, Can someone provide guidance on how to make the form field response values “read-only” so they can be shown to respondents but not edited by them?   

And finally: Is there another way to pass embedded data values to a Loop & Merge block to be used as piped text that changes with each loop of the block? I want the Loop & Merge to loop for each child that a parent/guardian consented to have participate in a study. The names of the children are passed into the survey as embedded data values via the redirect URL query string from a separate consent survey. I had tried placing these embedded data values directly in Field 2 of the Loop & Merge setup (referencing them, for example, as ${e://Field/Child1}, ${e://Field/Child2}, etc.). I then used Piped Text in the Loop & Merge questions to try to display the child names using ${lm://Field/2}. However, when I tested the survey the names were not showing up in the question text within the Loop & Merge block, even though they were showing up in the saved dataset and in the question text that was displayed in the Response Summary. I therefore switched to using a hidden form question to save these values as question response values as a work-around.

I would greatly appreciate any insight you can provide!

 

Thank you. 

Use below code instead for auto-forwarding:

if(!jQuery('div').hasClass("ResponseSummary")){
jQuery('#'+this.questionId).hide();
this.clickNextButton();
}

 

  


@Shashi, That worked, thank you!! The hidden question now shows up in my Response Summary (I’m not sure if it did before or not because the Response Summary didn’t stay on the screen long enough for me to check), but that’s okay. Thank you so much for your help!


Leave a Reply