The skipif
tag is used to dynamically display questions, tables, or text when a specified condition is true.
1. Which of the following cities have you visited before?
type: checkbox
1. New York
2. Boston
3. Chicago
4. Denver
5. Los Angeles
2. When was the last time you visited Boston?
type: radio
skipif: noneChecked($Q1,2)
1. Within the last month
2. 1-2 mos. ago
3. 3-5 mos. ago
4. 6-12 mos. ago
5. Over a year ago
Tip! The showif
tag is the opposite of skipif
and may be preferable to match logic specified in a client-copy of a survey.
Details
-
skipif
can be applied to most widgets and question types, though it should not be applied to blocks, groups, or anew page
widget. Instead include thecondition
tag with these widgets. - The
skipif
condition can reference content on the same page or elsewhere within the survey. - A widget with a
skipif
tag requires an answer only if it's not skipped and shown to the respondent. - The
skip if only options
,skip if only rows
, andskip if only columns
tags can be applied to any question or table where, based on a previous selection, only a single option, row, or column would be shown to the respondent. Multiple element IDs can be specified in the tags as well (e.g.,skip if only options: 98,99
). - A question or table containing a "skip if only" tag is only skipped; responses are not autocoded.
Additional examples
Using 'skipif' with 'showtext'
The skipif
tag can be used with the showtext
widget to dynamically display other content such as text, HTML, images, etc. In the following example, the showtext "ST_FAN" will be skipped if the respondent chooses 'Not really' or 'What's Star Trek?' in Q3.
3. Are you a Star Trek fan?
type: radio
1. Definitely
2. Sort of
3. Not really
4. What's Star Trek?
showtext: ST_FAN
text: <p>Live long and prosper!</p>
skipif: noneChecked($Q3,1,2)
Displaying table rows or columns
Table rows and columns can include dynamic variable references. To hide a table row, place a skipif
tag on that row or column definition. In the example below, the second row in T5 will be hidden if the respondent's answer in Q4 is less than '5'.
The start table
widget is required to apply skipif
to the row.
4. How long have you been in business?
type: integer
range: 0-60
postfix: years
start table: 5
size: 12
type: text
1. Who is currently your primary distributor?
2. Who was your primary distributor <b>5 years ago</b>?
skipif: $Q4 < 5
end table
The skipif
tag can also be used to dynamically hide table rows and columns in multi-part tables. In such cases, rows or columns can reference other variables, or other parts within the table. In T8, column 1 is hidden if a response less than '5' was provided at Q6, and column 3 is hidden if 'No' was selected in Q7.
The ifnotset: 0
tag is included so that when a cell is not displayed in a column, it is autocoded to '0'.
6. How long have you been in business?
type: integer
range: 0-60
postfix: years
7. Do you anticipate being in business 5 years from now?
type: radio
1. Yes
2. No
start table: 8
intro: What percent of your usage was insource and outsourced?
type: integer
ap: n
range: 0-100
showcolumntotal: Total {total: 100}
if not set: 0
postfix: %
rows:
1. Insourced
2. Outsourced
--
colid: 1
headings: 5 years ago
skipif: $Q6 < 5
--
colid: 2
headings: Today
--
colid: 3
headings: 5 years from now
skipif: $Q7 == 2
end table
Skip if only option, row, or column
The skip if only options
/rows
/columns
tags can be used to skip a question or table based on a lack of selections being piped (pulled) in from a previous question. For example, if only options '98' or '99' are selected in Q13, then Q14 and T15 will not have brands to rate and will be skipped.
13. Which of the following peanut butter brands have you previously purchased?
type: checkbox
randomize: y
1. Jif
2. Skippy
3. Peter Pan
4. Planter's
5. Smart Balance
98. I'm allergic to peanuts {exclusive: 1,2,3,4,5}
99. I don't buy peanut butter {exclusive: 1,2,3,4,5}
14. Which of these brands of peanut butter is your favorite?
type: radio
optsfrom: Q13.options {if anyChecked($Q13,[id])}
skip if only options: 98,99
15. On a scale of 1-5, how would you rate these peanut butter brands?
type: radio table
optsfrom: series[1..5]
rowsfrom: Q13.options {if anyChecked($Q13,[id])}
skip if only rows: 98,99
Comments
0 comments
Please sign in to leave a comment.