Survey.StylesManager.applyTheme("orange");
var json = {
"pages": [
{
"name": "page1",
"elements": [
{ "type": "rating", "name": "satisfaction", "title": "How satisfied are you with the Product?", "mininumRateDescription": "Not Satisfied", "maximumRateDescription": "Completely satisfied" },
{
"type": "panel",
"innerIndent": 1,
"name": "panel1",
"title": "Please, help us improve our product",
"visibleIf": "{satisfaction} < 3",
"elements": [
{
"type": "checkbox",
"choices": [
{
"value": "1",
"text": "Customer relationship"
},
{
"value": "2",
"text": "Service quality"
},
{
"value": "3",
"text": "Support response time"
}
],
"name": "What should be improved?"
},
{
"type": "comment",
"name": "suggestions",
"title": "What would make you more satisfied with the Product?"
},
{
"type": "panel", "innerIndent": 1, "name": "panel2", "title": "Send us your contact information (optionally)", "state": "collapsed",
"elements": [
{ "type": "text","name": "name", "title": "Name:" },
{ "type": "text", "inputType": "email","name": "email", "title": "E-mail" }
]
}
]
}
]
}
]
};
window.survey = new Survey.Model(json);
survey.onComplete.add(function(result) {
document.querySelector('#surveyResult').textContent =
"Result JSON:\n" + JSON.stringify(result.data, null, 3);
});
survey.data = {satisfaction: 2};
ReactDOM.render(<Survey.Survey model={survey} />, document.getElementById("surveyElement"));
<!DOCTYPE html>
<html lang="en">
<head>
<title>Container - Create a complex layout by using Panel element, Reactjs Survey Library Example</title>
<meta name="viewport" content="width=device-width" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.6.0/polyfill.js"></script>
<script src="https://unpkg.com/react@16.5.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.5.0/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.2.5/babel.min.js"></script>
<script src="/DevBuilds/survey-react/survey.react.min.js"></script>
<link href="/DevBuilds/survey-knockout/survey.min.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/babel" src="./index.js"></script>
</body>
</html>