Documentation Docs
Documentation Docs

Continue an Incomplete Survey

Your respondents may not complete your survey in a single session. In this case, you can restore their answers from the previous session next time they get to the survey. Incomplete results can be loaded from your database or the browser's localStorage.

To save incomplete results, enable the Survey's sendResultOnPageNext property. With this setting, the Survey raises the onPartialSend event each time a respondent navigates to the next survey page. Handle this event to send incomplete results to your database or localStorage:

import { Model } from "survey-core";

const surveyJson = { ... };
const survey = new Model(surveyJson);

survey.sendResultOnPageNext = true;

const storageItemKey = "my-survey";

function saveSurveyData (survey) {
  const data = survey.data;
  data.pageNo = survey.currentPageNo;
  window.localStorage.setItem(storageItemKey, JSON.stringify(data));
}

// Save survey results
survey.onPartialSend.add((survey) => {
  saveSurveyData(survey);
});
survey.onComplete.add((survey) => {
  saveSurveyData(survey);
});

// Restore survey results
const prevData = window.localStorage.getItem(storageItemKey) || null;
if (prevData) {
  const data = JSON.parse(prevData);
  survey.data = data;
  if (data.pageNo) {
    survey.currentPageNo = data.pageNo;
  }
}

View Demo

See Also

Copyright © 2023 Devsoft Baltic OÜ. All rights reserved.

Why we use cookies.

This site uses cookies to make your browsing experience more convenient and personal. Cookies store useful information on your computer to help us improve the efficiency and relevance of our site for you. In some cases, they are essential to making the site work properly. By accessing this site, you consent to the use of cookies.

For more information, refer to DevSoft Baltic’ privacy policy and cookie policy.

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.