Give specific button texts for certain pages on a survey
Change button text snippet example image
Instructions
How to add JavaScript to a survey
With this snippet, you can customize button texts on specific survey pages. You can define the texts for each page in the two objects nextButtonTexstPerPage
and previousButtonTextsPerPage
that appear in the beginning of the code.
For example, the key-value pair "0": "Next on first page"
in object nextButtonTextsPerPage
means that the Next-button on the first page of the survey will have text "Next on first page".
<script>
jQuery(document).ready(function(){
// Edit these objects to get custom texts to your survey form.
// E.g. first page will now have the text "Next on first page" on the Next-button
var nextButtonTextsPerPage = {
"0": "Next on first page",
"1": "Next on second page",
"2": "Next on third page"
};
var previousButtonTextsPerPage = {
"1": "Previous on second page"
};
// Get texts for current page
var pageNum = SurveypalAPI.getPage();
var nextButtonText = nextButtonTextsPerPage[pageNum];
var previousButtonText = previousButtonTextsPerPage[pageNum];
// If custom texts exist for this page, use them
if (nextButtonText) {jQuery("button.primary.right").text(nextButtonText)};
if (previousButtonText) {jQuery("button.left.prev").text(previousButtonText)};
});
</script>