This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:create:filter-boolean [10.12.2014 15:05] – [Linking Multiple Conditions] alexander.ritter | en:create:filter-boolean [23.10.2026 14:44] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| It may be necessary to link multiple conditions for a filter ([[filters|Filters and Conditional Questions]]). Some examples of these links: | It may be necessary to link multiple conditions for a filter ([[filters|Filters and Conditional Questions]]). Some examples of these links: | ||
| - | * Did the respondent select the option " | + | * Did the respondent select the option " |
| * Did the respondent state that he owned a car **and** it has a gas engine? | * Did the respondent state that he owned a car **and** it has a gas engine? | ||
| * Does the respondent **neither** watch the news on TV **nor** read it in the paper? | * Does the respondent **neither** watch the news on TV **nor** read it in the paper? | ||
| Line 17: | Line 17: | ||
| <code php> | <code php> | ||
| - | (value(' | + | (value(' |
| - | (value(' | + | (value(' |
| </ | </ | ||
| Line 33: | Line 33: | ||
| * '' | * '' | ||
| - | An '' | + | An '' |
| <code php> | <code php> | ||
| - | (value(' | + | (value(' |
| </ | </ | ||
| - | In this example, the inner brackets would not be essential because the '' | + | In this example, the inner brackets would not be essential because the '' |
| In IF filters, the whole condition is put in round brackets again (because the condition is always put in brackets when using the IF function). A filter with the linked condition therefore looks as follows: | In IF filters, the whole condition is put in round brackets again (because the condition is always put in brackets when using the IF function). A filter with the linked condition therefore looks as follows: | ||
| - | |||
| <code php> | <code php> | ||
| - | if ((value(' | + | if ((value(' |
| question(' | question(' | ||
| } | } | ||
| Line 54: | Line 53: | ||
| <code php> | <code php> | ||
| if ( | if ( | ||
| - | (value(' | + | (value(' |
| (value(' | (value(' | ||
| ) { | ) { | ||
| Line 65: | Line 64: | ||
| ===== The One OR the Other Condition is True ===== | ===== The One OR the Other Condition is True ===== | ||
| - | The following example shows a check as to whether at least one of the first three items from the question displayed above was chosen (owns a computer, DSL connection or cell phone). | + | The following example shows a check as to whether at least one of the first three items from the question displayed above was chosen (owns a computer, DSL connection or cell phone). |
| <code php> | <code php> | ||
| if ( | if ( | ||
| - | (value(' | + | (value(' |
| - | (value(' | + | (value(' |
| (value(' | (value(' | ||
| ) { | ) { | ||
| // display a text on the screen | // display a text on the screen | ||
| - | html('< | + | html('< |
| } else { | } else { | ||
| // none selected: end survey | // none selected: end survey | ||
| Line 91: | Line 90: | ||
| <code php> | <code php> | ||
| - | if ((value(' | + | if ((value(' |
| question(' | question(' | ||
| } | } | ||
| Line 101: | Line 100: | ||
| <code php> | <code php> | ||
| if ( | if ( | ||
| - | (value(' | + | (value(' |
| - | (value(' | + | (value(' |
| (value(' | (value(' | ||
| ) { | ) { | ||
| Line 113: | Line 112: | ||
| <code php> | <code php> | ||
| $a1 = value(' | $a1 = value(' | ||
| - | if (($a1 == 1) or ($a1 == 2) or ($a1 == 3)) { | + | if (($a1 == 1) || ($a1 == 2) || ($a1 == 3)) { |
| question(' | question(' | ||
| } | } | ||
| Line 158: | Line 157: | ||
| <code php> | <code php> | ||
| if (!( | if (!( | ||
| - | (value(' | + | (value(' |
| - | (value(' | + | (value(' |
| (value(' | (value(' | ||
| )) { | )) { | ||
| Line 166: | Line 165: | ||
| </ | </ | ||
| - | The only difference between this and the OR example above is the exclamation point, which is equivalent to '' | + | The only difference between this and the OR example above is the exclamation point ('' |
| In addition, there is a mathematical distributive law when calculating with the NOT operator. The following filter has the same effect as the previous one: | In addition, there is a mathematical distributive law when calculating with the NOT operator. The following filter has the same effect as the previous one: | ||
| Line 173: | Line 172: | ||
| <code php> | <code php> | ||
| if ( | if ( | ||
| - | (value(' | + | (value(' |
| - | (value(' | + | (value(' |
| (value(' | (value(' | ||
| ) { | ) { | ||
| Line 185: | Line 184: | ||
| <code php> | <code php> | ||
| if ( | if ( | ||
| - | (value(' | + | (value(' |
| - | (value(' | + | (value(' |
| (value(' | (value(' | ||
| ) { | ) { | ||
| Line 192: | Line 191: | ||
| } else { | } else { | ||
| goToPage(' | goToPage(' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Nested filters ===== | ||
| + | |||
| + | Sometimes it makes sense to set a filter in another filter. Let's take the situation where, depending on the answer to FF01, either question FF02 or FF03 was displayed. And now, depending on these two questions, another filter should follow. The individual filters would be simple: | ||
| + | |||
| + | <code php> | ||
| + | if (value(' | ||
| + | replace(' | ||
| + | } else { | ||
| + | replace(' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <code php> | ||
| + | if (value(' | ||
| + | replace(' | ||
| + | } else { | ||
| + | replace(' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | But now only one of these two filters should become active ... depending on which value FF01 had. To do this, these filters are placed " | ||
| + | |||
| + | <code php> | ||
| + | if (value(' | ||
| + | // Filter für FF02 | ||
| + | if (value(' | ||
| + | replace(' | ||
| + | } else { | ||
| + | replace(' | ||
| + | } | ||
| + | } else { | ||
| + | // Filter für FF03 | ||
| + | if (value(' | ||
| + | replace(' | ||
| + | } else { | ||
| + | replace(' | ||
| + | } | ||
| } | } | ||
| </ | </ | ||