Continue an Incomplete Survey
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. This demo shows how to save and restore incomplete survey results and the last visited question and page from the localStorage. To test this functionality, answer a couple of questions and reload the page. Your answers should persist. For information on how to save incomplete results on a server, refer to the following help topic: Restore Survey Progress from a Database.
Save Incomplete Survey Results
To save incomplete results, implement functions that send survey data and UI state to your server or store them in the localStorage (see the saveSurveyData and saveSurveyUIState functions in the code). Call these functions inside the SurveyModel's onValueChanged and onUIStateChanged event handlers to capture updates whenever users change a value or modify the UI (for example, expand/collapse a question box or switch pages). If you use the localStorage, also handle the onComplete event to submit the final results to the server and remove them from the localStorage, as they no longer need to be restored.
localStorageis limited to 5 MB of data per domain. If you expect incomplete responses to exceed this limit (which may happen if they contain encoded images or files), store them in a database.
Restore Survey Progress
To restore results, retrieve the saved data from your server or localStorage and assign it to the SurveyModel's data property. If you've also stored the UI state, assign it to the uiState property.