Boolean

Yes/No or True/False question - Boolean question

                        



var json = { questions: [
  {
    "type": "boolean",
    "name": "bool",
    "title": "Please answer the question",
    "label": "Are you 21 or older?",
    "isRequired": true
  }
]};

window.survey = new Survey.Model(json);


survey.onComplete.add(function(result) {
    document.querySelector('#surveyResult').innerHTML = "result: " + JSON.stringify(result.data);
});


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


                    
<!DOCTYPE html>
<html>
<head>
    <title>Yes/No or True/False question - Boolean question, jQuery Survey Library Example</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://unpkg.com/jquery"></script>
<script src="https://surveyjs.azureedge.net/1.0.44/survey.jquery.js"></script>
<link href="https://surveyjs.azureedge.net/1.0.44/survey.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="./index.css">

</head>
<body>
                <div id="surveyElement">
            </div>
    <div id="surveyResult"></div>

<script type="text/javascript" src="./index.js"></script>

</body>
</html>

defaultValue: (default is 'indeterminate'). The value showed by default.

var q = survey.getQuestionByName('bool');
survey.clear();
q.defaultValue = yourvalue; 
//restart the survey
survey.render();

var q = survey.getQuestionByName('bool');
q.showTitle = yourvalue; 
survey.render();

valueTrue

var q = survey.getQuestionByName('bool');
q.valueTrue = yourvalue; 
survey.render();

valueFalse

var q = survey.getQuestionByName('bool');
q.valueFalse = yourvalue; 
survey.render();