How to create an exit button? Previously found codes aren't working! | XM Community
Question

How to create an exit button? Previously found codes aren't working!

  • 16 October 2019
  • 2 replies
  • 101 views

Hello everyone,
I am a graduate student desperately looking for a way to include an emergency exit button at the bottom of my survey that would direct the participant to the end of the survey. I have tried every code out there but nothing is working. The only button I have found to work can direct them to another URL but I need a way to get them to end of the survey (which doesn't have a distinct URL) so they can be compensated. If anyone is able to provide a code or help me interpret other codes I have found online, I would be so grateful! It's possible that I have placed them incorrectly in the survey, I have had trouble understanding the embedded data function.
Thank you!

2 replies

Userlevel 2
Badge +1
As a workaround, you can use a Y/N type question asking the survey taker if they want to continue with the survey, and then by using a branch logic within the Survey Flow add the "End of Survey" element to redirect the survey taker to the end of the Survey.
Userlevel 7
Badge +27

You could put this in place by having a button in the survey's Footer that sets an Embedded Data field and advances the page when clicked. Then, use Branching or Display logic to direct the respondent to the end of the survey if the Embedded Data field is equal to "true".

To give it a try, first create an Embedded Data field at the top of the Survey Flow called "exit" and set its value to "false".

Then in the Look & Feel, add the below to the Footer to insert a button:

<button type="button" id="exit">Exit</button>

Then add the below to the Header to turn the Embedded Data field "exit" to "true" and advance the page when the button is clicked:

<script>
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#exit").on('click',function(){
Qualtrics.SurveyEngine.setEmbeddedData("exit", "true");
jQuery("#NextButton").click();
});
});
</script>

Finally, add Display Logic to the rest of the questions so that they only display if "exit" is equal to "false". Or, add Branching to the Survey Flow after each page which directs the respondent to an End of Survey element if "exit" is equal to "true".

Leave a Reply