Allow your clients/users run survey only one time.
Open in new window

Send the survey results before moving on the next Page default is false.

If you have a long survey, many your users may not finish the survey and enter the data on few pagers on only the first one. If you still want to save the information from incompleted surveys, set this property to true. The clientId property should bet set correctly, otherwise the data of others users may be ovewritten.

survey.sendResultOnPageNext = yourvalue;


Survey.defaultBootstrapCss.navigationButton = "btn btn-green";
Survey.Survey.cssType = "bootstrap";

var clientId;

runSurveyCheck();

function runSurveyCheck() {
    clientId = document.getElementById('clientIdinput').value || 'e2bd506a-a218-4f5c-b8ae-768f203e399b';
    new Survey.dxSurveyService().isCompleted('47e699f7-d523-4476-8fcd-be601c91d119', clientId, onCheckCompleted);
}

function onCheckCompleted(success, result, response) {
    if(!success) return;
    if(result == 'completed') {
        alert('You have already run the survey!');
    } else {
        runSurvey();
    }
}


function runSurvey() {
    window.survey = new Survey.Model({
            surveyId: 'e7866476-e901-4ab7-9f38-574416387f73',
            surveyPostId: 'df2a04fb-ce9b-44a6-a6a7-6183ac555a68'
    }, "surveyElement");
    
    survey.onComplete.add(function(result) {
    	document.querySelector('#surveyResult').innerHTML = "result: " + JSON.stringify(result.data);
    });
    
    survey.onSendResult.add(function (survey) { 
        var text = "clientId:" + survey.clientId + ". The results are:" + JSON.stringify(survey.data)  + String.fromCharCode(13, 10);
        var memo = document.getElementById('serverResultArea');
        memo.value = memo.value + text;
    });
    
    survey.sendResultOnPageNext = true;
    survey.clientId = clientId;

    $("#surveyElement").Survey({model:survey});

}


<!DOCTYPE html>
<html>

<head>
    <title>Welcome to JQuery</title>
    <script src="https://unpkg.com/jquery"></script>
    
    <script src="https://surveyjs.azureedge.net/0.12.18/survey.jquery.js"></script>
    
    
    <link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="./index.css">
</head>

<body>
    <button onclick="runSurveyCheck()">Rerun Survey</button>
    <dl>
      <dt>survey.clientId:</dt>
       <dd> <input id="clientIdinput" placeholder="e2bd506a-a218-4f5c-b8ae-768f203e399b"/> </dd>
      <dt>Survey results sent to the server:</dt>
       <dd> <textarea id="serverResultArea" rows="5" cols="50"></textarea> </dd>
    </dl>
    <hr/>
    
    <div id="surveyElement"></div>
    <div id="surveyResult"></div>
    <script src="./index.js"></script>
</body>

</html>

.btn-green {
  background-color: #1ab394;
  color: #fff;
  border-radius: 3px;
}

.btn-green:hover, .btn-green:focus {
    background-color: #18a689;
    color: #fff;
}

.panel-footer {
    text-align: right;
    background-color: #fff;
}