Javascript to end survey in Qualtrics

2.3k views Asked by At

I am somewhat new to Qualtrics and the Javascript API they offer, and I have been exploring ways in which to end a lengthy survey at any point during the course of survey.

The survey will be given over the phone and many participants drop out midway. To save time, it would be great to have an "END SURVEY NOW" button on every page.

This appears to be possible with the navclick function, but I am unclear about the exact implementation.

Any suggestions are appreciated.

1

There are 1 answers

0
Sky On BEST ANSWER

These instructions will help you to create a button at the bottom of every page that will allow a user to skip to the end of the survey at any point. It uses a hidden question, javascript, and built-in skip logic. Let's begin.

You can create a button at the bottom of every page by adding some HTML to the footer section.

<button id="EndNow" name="EndNowBtn" title="EndNow" type="button">End Survey Now</button>

You can always add some CSS to style the button to match the theme. For my survey, I added:

#EndNow {
width: 200px;
padding: 10px;
font-size: 25px;
border-radius: 5px;
color: white;
background-color: #D11F40;
border: none;   
}

Then, add a multiple choice question with only one answer to the end of every page. This will be our "Skip" question. Add skip logic to the question that basically says, "If Choice 1 is selected, skip to the end of the survey". Add this Javascript to every Skip question:

Qualtrics.SurveyEngine.addOnload(function() {
$(this.question._$separator).hide();
$(this.questionId).hide();
var that = this;
var endBtn = document.getElementById("EndNow");

function skip() {
    that.setChoiceValue(1, true);
    that.clickNextButton();
};

endBtn.addEventListener("click", skip);
});

Note: This code snippet includes the wrapper that is pre-populated in the Custom Javascript Editor.

The Javascript will hide the Skip question and select the first choice whenever a respondent clicks the "End Survey Now" button (which will skip them to the end of the survey).