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 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.
To save incomplete results, implement a function that sends them to your server or saves them in the localStorage
(see the saveSurveyData
function in code). Call this function within SurveyModel
's onValueChanged
and onCurrentPageChanged
event handlers to save the results when users change a question value or switch between pages. If you use the localStorage
, handle the onComplete
event to submit final survey results to the server and delete them from the localStorage
because they no longer need to be restored.
To restore survey results, retrieve them from your server or localStorage
and assign them to SurveyModel
's data
property. If you also saved the page number from which a respondent left off, assign it to SurveyModel
's currentPageNo
property.