-
Templates
-
Simple Questions
-
Text Entry
-
Date-Time Entry
-
Numeric Entry
-
Color Input
-
Radio Button Group
-
Radio group with Custom Item Template
-
Drop-Down Menu
-
Dropdown: Load Data from Web Services
-
Dropdown with Custom Item Template
-
Dropdown with Lazy Loading
-
Multi-Select Dropdown
-
Checkboxes
-
Carry Forward Responses
-
Image Picker
-
Yes/No Question
-
Signature Pad
-
Multiple Text
-
Rating
-
Ranking
-
Comment
-
Image
-
Html
-
File
-
Expression
-
Expression (using async functions)
-
-
Matrix Table Questions
-
Panel & Dynamic Panel
-
Survey
-
Title and Logo
-
Questions in one line
-
Survey Options
-
Auto-Populate Form Fields
-
Piped Text
-
Edit saved survey
-
Read-only/display mode
-
Show Preview before complete
-
Pop-Up Survey
-
Context actions in element titles
-
Modify title tags
-
Custom render of survey elements
-
File - custom preview
-
File - delayed upload
-
Lazy questions rendering
-
-
Quizzes and Scored Surveys
-
Integration with Third-Party Libraries
-
Appearance customization
-
Navigation
-
Conditions and Triggers
-
VisibleIf
-
Simplify Cascade Conditions
-
Complex questions in expressions
-
Use custom function in expressions
-
Create custom condition/expression properties
-
Conditions in dynamic questions
-
Show/Hide choices in radiogroup/checkbox/dropdown
-
Show/Hide individual items in radiogroup/checkbox/dropdown
-
Show/Hide columns/rows in matrix question
-
Show/Hide rows in matrix dropdown question
-
EnableIf
-
Complete Trigger
-
CopyValue Trigger
-
SetValue Trigger
-
Run Expression Trigger
-
-
Text Formatting
-
Survey Localization
-
Input Validation
-
SurveyJS Storage
Conditions in dynamic questions
Survey.StylesManager.applyTheme("defaultV2");
var json = {
questions:[
{
type: "matrixdynamic",
name: "frameworksRateMatrix",
"minRowCount": 4,
"maxRowCount": 4,
"valueName": "frameworksRate",
title: "Please tells us about JavaScript frameworks you are using (Matrix Dynamic)",
columns: [
{
"name": "framework",
"title": "Framework",
"cellType": "text",
"readOnly": true
},
{
name: "using",
title: "Do you use it?",
"isRequired": true,
choices: [
"Yes",
"No"
],
cellType: "radiogroup"
},
{
name: "experience",
title: "How long do you use it?",
cellType: "dropdown",
"visibleIf": "{row.using} = 'Yes'",
"isRequired": true,
choices: [
{
value: 5,
text: "3-5 years"
},
{
value: 2,
text: "1-2 years"
},
{
value: 1,
text: "less then a year"
}
]
}
]
},
{
type: "paneldynamic",
name: "frameworksRatePanel",
"minPanelCount": 4, "maxPanelCount": 4,
"valueName": "frameworksRate",
title: "Please tells us about JavaScript frameworks you are using (Panel Dynamic)",
templateElements: [
{
"name": "framework",
"title": "Framework",
"type": "text",
"readOnly": true
},
{
name: "using",
title: "Do you use it?",
"type": "radiogroup",
"colCount": 0,
"startWithNewLine": false,
"isRequired": true,
choices: [
"Yes",
"No"
],
cellType: "radiogroup"
},
{
name: "experience",
title: "How long do you use it?",
"type": "dropdown",
"visibleIf": "{panel.using} = 'Yes'",
"isRequired": true,
"startWithNewLine": false,
choices: [
{
value: 5,
text: "3-5 years"
},
{
value: 2,
text: "1-2 years"
},
{
value: 1,
text: "less then a year"
}
]
}
]
}
]
};
window.survey = new Survey.Model(json);
survey.onComplete.add(function(sender) {
document.querySelector('#surveyResult').textContent =
"Result JSON:\n" + JSON.stringify(sender.data, null, 3);
});
survey.data = {'frameworksRate': [{'framework':'angular v1'},{'framework':'angular v2+'},{'framework':'react'}, {'framework':'vue'}]};
ReactDOM.render(
<SurveyReact.Survey model={survey} />, document.getElementById("surveyElement"));
<!DOCTYPE html>
<html lang="en">
<head>
<title>Conditions in dynamic questions, Reactjs Survey Library Example</title>
<meta name="viewport" content="width=device-width" />
<script src="https://unpkg.com/react@17.0.1/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.1/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.2.5/babel.min.js"></script>
<script src="/DevBuilds/survey-core/survey.core.min.js"></script>
<script src="/DevBuilds/survey-core/survey.i18n.min.js"></script>
<script src="/DevBuilds/survey-react-ui/survey-react-ui.min.js"></script>
<link href="/DevBuilds/survey-core/defaultV2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="./index.css">
</head>
<body style="margin: 0">
<div id="surveyElement" style="display:inline-block;width:100%;">
</div>
<div id="surveyResult"></div>
<script type="text/babel" src="./index.js"></script>
</body>
</html>
Loading...
Sorry, we can't retrieve the data from server. Please comeback later.
In this example we are using two questions bound to the same data. Their valueName property equals to "frameworksRate".
"How long do you use it?" cell in matrix and question in panel are shown based on "Do you use it?" question in corresponded row or panel.
To access the value of the current row/panel you have to use prefix row. or panel..
Example for a matrix column:
visibleIf: "{row.using} = 'Yes'"Example for a question in dynamic panel
visibleIf: "{panel.using} = 'Yes'"
-
Templates
-
Simple Questions
-
Text Entry
-
Date-Time Entry
-
Numeric Entry
-
Color Input
-
Radio Button Group
-
Radio group with Custom Item Template
-
Drop-Down Menu
-
Dropdown: Load Data from Web Services
-
Dropdown with Custom Item Template
-
Dropdown with Lazy Loading
-
Multi-Select Dropdown
-
Checkboxes
-
Carry Forward Responses
-
Image Picker
-
Yes/No Question
-
Signature Pad
-
Multiple Text
-
Rating
-
Ranking
-
Comment
-
Image
-
Html
-
File
-
Expression
-
Expression (using async functions)
-
-
Matrix Table Questions
-
Panel & Dynamic Panel
-
Survey
-
Title and Logo
-
Questions in one line
-
Survey Options
-
Auto-Populate Form Fields
-
Piped Text
-
Edit saved survey
-
Read-only/display mode
-
Show Preview before complete
-
Pop-Up Survey
-
Context actions in element titles
-
Modify title tags
-
Custom render of survey elements
-
File - custom preview
-
File - delayed upload
-
Lazy questions rendering
-
-
Quizzes and Scored Surveys
-
Integration with Third-Party Libraries
-
Appearance customization
-
Navigation
-
Conditions and Triggers
-
VisibleIf
-
Simplify Cascade Conditions
-
Complex questions in expressions
-
Use custom function in expressions
-
Create custom condition/expression properties
-
Conditions in dynamic questions
-
Show/Hide choices in radiogroup/checkbox/dropdown
-
Show/Hide individual items in radiogroup/checkbox/dropdown
-
Show/Hide columns/rows in matrix question
-
Show/Hide rows in matrix dropdown question
-
EnableIf
-
Complete Trigger
-
CopyValue Trigger
-
SetValue Trigger
-
Run Expression Trigger
-
-
Text Formatting
-
Survey Localization
-
Input Validation
-
SurveyJS Storage