Survey.StylesManager.applyTheme("modern");
var json = {
"elements": [
{
"type": "checkbox",
"name": "car",
"isRequired": true,
"title": "What cars have you being drived?",
"colCount": 4,
"choicesOrder": "asc",
"choices": [
"Ford",
"Vauxhall",
"Volkswagen",
"Nissan",
"Audi",
"Mercedes-Benz",
"BMW",
"Peugeot",
"Toyota",
"Citroen",
"Tesla"
]
},
{
"type": "radiogroup",
"name": "bestcar",
"isRequired": true,
"colCount": 4,
"visibleIf": "{car} notempty",
"title": "What car did you enjoy the most?",
"choicesFromQuestion": "car",
"choicesFromQuestionMode": "selected"
},
{
"type": "radiogroup",
"name": "secondcar",
"isRequired": true,
"colCount": 4,
"visibleIf": "{car.length} > 1",
"title": "What car is your second choice?",
"choicesFromQuestion": "bestcar",
"choicesFromQuestionMode": "unselected"
}
]
};
window.survey = new Survey.Model(json);
survey.onComplete.add(function(result) {
document.querySelector('#surveyResult').textContent =
"Result JSON:\n" + JSON.stringify(result.data, null, 3);
});
$("#surveyElement").Survey({
model: survey
});
<!DOCTYPE html>
<html lang="en">
<head>
<title>Select choice questions - Share choices and optionally filter them., jQuery Survey Library Example</title>
<meta name="viewport" content="width=device-width" />
<script src="https://unpkg.com/jquery"></script>
<script src="/DevBuilds/survey-jquery/survey.jquery.min.js"></script>
<link href="/DevBuilds/survey-knockout/modern.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div id="surveyElement" style="display:inline-block;width:100%;">
</div>
<div id="surveyResult"></div>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>