Skip to content

Commit

Permalink
Update the Conditional Logic help topic
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanTsukanov committed Oct 17, 2023
1 parent 3f73721 commit 4899e46
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/design-survey-conditional-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,23 +632,24 @@ This technique has one drawback: if a question contains many items, you have to

You can specify one expression that will run against every item (choice, row, column). If the expression evaluates to `true`, the item becomes visible. Assign your expression to the [`choicesVisibleIf`](/Documentation/Library?id=QuestionSelectBase#choicesVisibleIf), [`rowsVisibleIf`](/Documentation/Library?id=questionmatrixmodel#rowsVisibleIf), or [`columnsVisibleIf`](/Documentation/Library?id=questionmatrixmodel#columnsVisibleIf) property. To access the current item, use the `{item}` operand.

The following code shows how to specify the `choicesVisibleIf` property. `choices` in the `"default"` question are filtered based on the `"installed"` question. `choices` in the `"secondChoice"` question depend on both the `"installed"` and `"default"` questions.
The following code shows how to specify the `choicesVisibleIf` property. The `"default"` question includes selected choices from the `"installed"` question. The `"secondChoice"` question also includes selected choices from the `"installed"` question, but uses the `choiceVisibleIf` property to filter out the choice selected in the `"default"` question.

```js
const surveyJson = {
"elements": [{
"name": "installed",
"choices": ["Chrome", "MS Edge", "FireFox", "Internet Explorer", "Safari", "Opera"],
"choices": ["Google Chrome", "Microsoft Edge", "Firefox", "Internet Explorer", "Safari", "Opera"],
// ...
}, {
"name": "default",
"choices": ["Chrome", "MS Edge", "FireFox", "Internet Explorer", "Safari", "Opera"],
"choicesVisibleIf": "{installed} contains {item}",
"choicesFromQuestion": "installed",
"choicesFromQuestionMode": "selected"
// ...
}, {
"name": "secondChoice",
"choices": ["Chrome", "MS Edge", "FireFox", "Internet Explorer", "Safari", "Opera"],
"choicesVisibleIf": "{installed} contains {item} and {item} != {default}",
"choicesFromQuestion": "installed",
"choicesFromQuestionMode": "selected",
"choicesVisibleIf": "{item} != {default}",
// ...
}]
}
Expand Down

0 comments on commit 4899e46

Please sign in to comment.