Is it possible to change the "Next" button to "Finish" based on embedded data? | XM Community
Skip to main content

I've used the following code before to change the next button (from https://community.qualtrics.com/XMcommunity/discussion/426/change-next-forward-button-on-final-page-to-submit-finish-etc)

Qualtrics.SurveyEngine.addOnReady(function() {
var newName = 'Finish & Submit'; //Update - New Next Button label
var lastLoopOnly = true; //Last loop only? Value doesn't matter to non-loops
//No changes below
if(!lastLoopOnly || "${lm://CurrentLoopNumber}" == "${lm://TotalLoops}") {
var nb = jQuery('#NextButton');
nb.val(newName);
nb.attr('title', newName);
}
});

This time, however there are two versions of my survey.

  • Version 1 has 4 questions

  • Version 2 has 8 questions

I have embedded logic in the survey flow to identify when to show questions 5-8.

I am using the code above for the 8th question and that works great to show 'Finish & Submit". In the Look and Feel --> General, I have my Next Button Text as "Next", which works great for Version 2.
But I'd like the 4th question to show "Finish & Submit" in Version 1. I tried putting the code above in question 4, but it did not work as expected. It showed "Finish & Submit" for question 4 in Version 2.
I was thinking the looping logic would identify if it was the end of the survey and only show it at that point.
So my thoughts are
  • Is it possible to have logic in the JavaScript to show the button as "Finish & Submit" based on my embedded data logic?

  • Or maybe it's an issue with the type of QualtricsSurveyEngine? Should it not be .addOnReady?

  • Or is there a different way to do the loop for it to identify the if the question is the last question?

Just get the version value (1 or 2) in onReady and then updated Next text as you want it to be.


https://community.qualtrics.com/XMcommunity/discussion/comment/43078#Comment_43078grahulp5 Thank you for the response! I apologize, I'm not quite sure I understand your solution.
Version 1 and Version 2 are both in a single survey. I distinguished them because depending on value the customer has for Embedded Data, then they'll see one or the other.
I'll give some more context of how the survey is built in the survey flow:
Show Block 1: questions 1-4
If Embedded Data is Equal to True, show Block 2: questions 5-8

I want question 4 to say "Finish & Submit" if Embedded data is not True, and to say "Next" if Embedded data is True.

Is you recommendation to add the Embedded Data to the code above?
What would that look like?

  • var EmbeddedData = ??

Thanks!


I found from another question on Qualtrics community that you can reference the embedded data like: "${e://Field/EmbeddedDataName} " 

I tried editing the logic like so, but it didn't work. Does anyone know why?
Qualtrics.SurveyEngine.addOnReady(function() {
if("${e://Field/EmbeddedDataName} " != "True"){
var newName = 'Finish & Submit'; //Update - New Next Button label
var lastLoopOnly = true; //Last loop only? Value doesn't matter to non-loops
//No changes below
if(!lastLoopOnly || "${lm://CurrentLoopNumber}" == "${lm://TotalLoops}") {
var nb = jQuery('#NextButton');
nb.val(newName);
nb.attr('title', newName);
}
}
});


Update -- the line of code I added had an extra space between the bracket and the quotation mark. (Ie. bolded here: if("${e://Field/EmbeddedDataName} " != "True")
After I removed the space, the code works 🙂

Functioning code:

Qualtrics.SurveyEngine.addOnReady(function() {
if("${e://Field/isProactive}" != "True"){
var newName = 'Finish & Submit'; //Update - New Next Button label
var lastLoopOnly = true; //Last loop only? Value doesn't matter to non-loops
//No changes below
if(!lastLoopOnly || "${lm://CurrentLoopNumber}" == "${lm://TotalLoops}") {
var nb = jQuery('#NextButton');
nb.val(newName);
nb.attr('title', newName);
}
}
});


https://community.qualtrics.com/XMcommunity/discussion/comment/43264#Comment_43264That's great Rfredman !!!


Leave a Reply