Click a button to skip to end of block | XM Community
Solved

Click a button to skip to end of block

  • 14 May 2021
  • 4 replies
  • 305 views

Hi, I want to create a clickable button so that if the participant clicks it, he will skip following questions and be directed to the survey page (end of block).
Here isae what i did:

  1. set embedded data: At the start of survey, i set embedded data "withdraw", value will be set from Panel or URL. Should i set its value be 0 here?

  2. I add branch logic: if withdraw is equal to 1, end of survey.

  3. i edit the question in the block:

html:
javascript:
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery('#myButton').on('click', () => {
  Qualtrics.SurveyEngine.setEmbeddedData("withdraw", 1);
});
I can see the Withdraw Button in the preview but click it does not bring me to the end of the survey. Why is this?

icon

Best answer by Mishraji 16 May 2021, 13:52

View original

4 replies

Userlevel 4
Badge +18

This is because you are only setting the embedded data and the branch logic is at end of the block and will not get executed automatically. Clicking the withdraw button is only setting the embedded data.
Once the embedded data is set in the above code, you should then click the next button for all subsequent questions if 'withdraw' is equal to 1. The next button click can be done using the following code:
jQuery("#NextButton").click();

https://www.qualtrics.com/community/discussion/comment/37393#Comment_37393Hi, thanks for you answer. I moved the set embedded data and branch to the start of survey instead of at the end the block. But it still doesnt work. When you say "the embedded data is set in the above code", what does this mean? what is the code? thanks

Userlevel 7
Badge +21

cm201623 have you searched the forum for "withdraw button". There are already pretty good explainers available. Some even deal with the exact same issue you are facing.

Userlevel 4
Badge +18

The survey flow should be somewhat like this:
image.png
When the withdraw button is clicked, you are setting the embedded data 'withdraw' to 1. Here, Update the JS to click the next button if withdraw = 1. This should be done for all questions. Below is an example:

Qualtrics.SurveyEngine.addOnReady(function()
{
var withdraw_val= "${e://Field/withdraw}";
if (withdraw_val==1) {
jQuery("#NextButton").click();
}

  jQuery('#myButton').on('click', () => {
  Qualtrics.SurveyEngine.setEmbeddedData("withdraw", 1);
  jQuery("#NextButton").click();
});
});

Leave a Reply