2

I want to automatically fill survey checkboxes based on results from a previous field in the same instrument. For my example, if respondents are using the red kit of tools, I want them to select yes in the initial toolkit question, so the subsequent checkbox fields about which types of tools is already answered to save time from filling out all the tools that are in the toolkit.

this is the field set up. Once kit 'Yes' is selected, I want red hammer and nails to be automatically selected

I see how to do this with text fields using @DEFAULT='[previous field name]', but I cannot make this work for checkboxes. Adding @DEFAULT='[kit]' into either the hammer or nail used fields doesn't result in automatically filled selection. It would also be nice if the action could be conditional, as in IF "Yes" for kit is selected THEN hammer='1', ELSE it would be left blank.

wibeasley
  • 5,000
  • 3
  • 34
  • 62
Warren
  • 21
  • 2

1 Answers1

2

See the built-in Help & FAQ on Piping:

If you are piping the answer FROM a multiple choice field (radio, drop-down), it will display the option label (not the coded data value) into the location where the field is piped. For example, if you had a drop-down question that said 'What is your favorite ice cream?' with the choices 'Chocolate', 'Vanilla', and 'Strawberry' (all coded as 0, 1, 2, respectively), then after selecting 'Chocolate', the next question would read 'On a scale of 1 to 10, how much to you like Chocolate?'.

But for non-multiple choice fields, such as Text, Notes, Slider fields, it will pipe the literal data value. If you wish to pipe the value (not the label) of a multiple choice field, append ':value' to the variable name inside brackets - e.g., [race:value].

Note: The usage of ':value' must be used if piping inside the @DEFAULT Action Tag if you would like to pipe the value of a multiple choice field as the default value of a field.

The default behaviour for piping from a categorical field (radio, dropdown, etc.) is to pipe the label (the text "Yes" in your example). However the checkbox fields you are using the @DEFAULT action tag to pipe values into, expect choice codes (values). Luckily, there is an option to pipe the value instead of the label, using [field:value].

So adding @DEFAULT='[kit:value]' to your hammer/nails fields is what you want.

But there is another issue; @DEFAULT is evaluated on page load, and so cannot do dynamic selection of a default value based on answers in the current page of the survey or form, using values in the database. It cannot use values in the current page if they are not in the database.

Typically, this is solved by separating the two fields by a page break (a new section field in the instrument, with the 'one section per page' option enabled in the survey settings). This way, the value of [kit] is committed to the database when the user clicks 'next page', and @DEFAULT can then read the value from the database and use it to automatically select one of the checkbox options.

One last consideration is that your coded values in your [kit] field and your hammer/nails fields must be compatible. If 1, Yes corresponds to 'red' for hammer and nails, then the 'red hammer' and 'red nails' options in those checkboxes should be coded as 1. @DEFAULT cannot perform any calculations or evaluate any logic, so you cannot use it to say something like 'IF "Yes" for kit is selected THEN hammer=1, ELSE leave it blank'; it works instead by taking a single parameter and using that parameter to select the choice automatically when the page loads and the fields are constructed (or inserting the parameter as text if it is a text input field). There is no scope in this process to evaluate any logic.

Jangari
  • 690
  • 4
  • 12