Javascript or other options for inserting an "exit survey" button | XM Community
Solved

Javascript or other options for inserting an "exit survey" button

  • 23 January 2019
  • 17 replies
  • 556 views

To meet ethical approval, I need to insert a functional button into each page of my survey. The button will say "Withdraw from survey" and appear at the bottom of each page in the centre (between the next/previous). Clicking the button should direct the participant to the post survey debrief information page. Is this possible? I am trying to refrain from entering a multiple choice question with a continue/withdraw option because of the visual appearance of this and feel that it would make participation feel more tedious given the length of the survey.
icon

Best answer by fleb 23 January 2019, 18:07

View original

17 replies

Userlevel 5
Badge +6
Hi @CSonn ,
if you and your ethical committee wouldn't mind having the Exit button little bit lower than the Next and Previous buttons, you can simply place the button with the link into the footer of your survey.
You can use for example the code in the file attached. (I'm not able to insert it here, nothing appears when I try.) Be aware, the code doesn't work in the Preview mode but it's OK in a published survey. You can find more simple possibilities how to create a button with a hyperlink here.
Thanks for this! This looks like the perfect solution. I couldn't open the txt attachment unfortunately.
I have created the button by going to (1) Look and Feel, (2) Advanced, (3) pasting the following code into the footer section (without the hash symbols and with a > at the end):
<#button id="EndNow" name="EndNowBtn" title="EndNow" type="button">Exit Survey</button#

The button appears. Would you happen to know what code I would need to enter after that so that clicking the button takes the participant to the last block in the survey?

I found the following code and tried entering it after but it didn't work - maybe I need some kind of small change to it?

jQuery("#EndNow").click(function()
{
jQuery("a[id='BlockID']").click();
});
Hello @CSonn ,

Place the below code in the footer (edit) -> (<>) "source" view to get a button in footer

`<input class="Button" id="ExitButton" name="ExitButton" title="Exit Survey" type="button" value="Exit Survey" />`
Thank you! I just edited my response above - sorry we must have both been responding at the same time
Any ideas on the second part? (i.e. linking to the end block?)
> @CSonn said:
> Any ideas on the second part? (i.e. linking to the end block?)

Second part is only possible if we have Table Of Content in the survey.
Thanks so much for your help Shashi! I won't have a table of content so this option won't work. I saw elsewhere that I can enter a skip-logic question on every page which is hidden but that clicking the Exit Survey button would link to the end block through this functionality. Wondering if there's a simpler way through coding the button? Any ideas? Or should I stick with the skip-logic option? Thanks again!
Hello @CSonn ,

In this scenario we need to go with "Skip Logic". Add a question at the end of each page and add skip logic to end of block. Show the "post survey debrief information page" using branch logic in survey flow after each block.

Please find the attached QSF for reference.
Thanks for this Shashi!
Thanks Shashi - I've just opened this file and see how to do this now. See it in an example was very helpful. Thanks again!
Nearly there! I just notice on testing that when I select the "exit survey" button (single answer multiple choice with skip logic) that it doesn't allow me to deselect the answer with a second click. Is there an option to do this? I found another thread that suggests making answers "exclusive" but I think the single answer option already does this (and couldn't find the "exclusive" option anywhere else)?
> @CSonn said:
> Nearly there! I just notice on testing that when I select the "exit survey" button (single answer multiple choice with skip logic) that it doesn't allow me to deselect the answer with a second click. Is there an option to do this? I found another thread that suggests making answers "exclusive" but I think the single answer option already does this (and couldn't find the "exclusive" option anywhere else)?

Just make that exit survey question as "Multiple Choice" -> "Multiple Answer" question type
Hi Shashi, I have a table of contents. How do we do the second part?
> @JStPierre said:
> Hi Shashi, I have a table of contents. How do we do the second part?

Please check the attached QSF
> @Shashi said:
> > @JStPierre said:
> > Hi Shashi, I have a table of contents. How do we do the second part?
>
> Please check the attached QSF
>
>

So, I imported it but it just created a whole new survey. We have the exit button from the javascript earlier. Is there a script to make the button work?
> @JStPierre said:
> > @Shashi said:
> > > @JStPierre said:
> > > Hi Shashi, I have a table of contents. How do we do the second part?
> >
> > Please check the attached QSF
> >
> >
>
> So, I imported it but it just created a whole new survey. We have the exit button from the javascript earlier. Is there a script to make the button work?

Please look at the setup of attached survey and try to replicate in your survey.

If you have exit button using javascript then create an embedded data exitsurvey and set value of this embedded data as 1 when exit button is clicked and hide all the future blocks using branch logic in survey flow
Badge +3
Please see these instructions. Then, add a block before the "end of survey" block, if you want.
Also, you can hide the footer on specific pages, using this javascript.

Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#WithdrawButton").hide();

});

Leave a Reply