====== Using an answer in later questions ======

One of the main advantages of an electronic questionnaire is that it can react dynamically to participants responses. This chapter provides a brief overview.

===== Filter questions =====

Filter question -- that means in the simplest case that questions/items are displayed or blended depending on the participant's answer ("Do you use Facebook?") in the later course of the questionnaire. In some cases the participant will also be excluded from further participation (Screenout).

  * [[:en:create:filters]]\\ Deatailed introduction in filter questions
  * ''[[:en:create:functions:pagestop]]''\\ The reference to this function contains an example of a screen-out filter.


==== Show selected items ====

A special case of filter questions is the transfer of selected items to another question.

Example: In a multiple selection, the online services that a participant uses are queried. Later on a scale is to be asked how often he uses the selected services.

  * [[:en:create:filter-items]]


==== Filter on the same page ====

Sometimes you do not want to wait until the participant clicks on "Continue", but when selecting an answer, another question is to be immediately faded in/out.

  * [[:en:create:dynamic]]
  * [[:en:create:questions:extselect]]\\ A question type that automatically displays child options to an option
  * [[:en:create:questions:assignment]]\\ With this type of question, further items can be automatically inserted / deactivated depending on the answer.


===== View responses =====

The participant has selected an answer ([[:en:create:questions:select]]) or typed ([[:en:create:questions:text]], [[:en:create:questions:suggest]]) -- and this answer will appear later in the questionnaire in the text, in a question or in items.

With [[:en:create:placeholders|Placeholders]] text nodes can be exchanged dynamically at any location. Once a placeholder has been defined, it is available throughout the following questionnaire.

  * [[:en:create:transfer-responses]]


===== Multiple survey waves =====

In the case of multi-wave surveys, participants should be able to display responses from an earlier survey wave. The implementation depends on how the multi-wave survey was technically designed.

  * **Breaker pages** -- documented in the reference to ''[[:en:create:functions:mailresume]]''\\ If it is technically a questionnaire, which can be displayed to the participant simply in several stages, then you can use ''[[:en:create:functions:value]]'' and ''[[:en:create:functions:replace]]'' as usual. Placeholder defined in a wave are also available in later waves.
  * **Different questionnaires** -- under the use of [[:en:survey:mailing|Mailing]]\\ If data is to be transmitted between different interviews, this works with [[:en:create:databank]]. For this purpose, the relevant data in the first survey has to be safed using ''[[:en:create:functions:dbset]]'' and recalled in later surveys using ''[[:en:create:functions:dbget]]''.

The following example shows the transmission of answers from Interview A to the later Interview B. The prerequisite is that the participants have been invited to the two survey waves by using [[:en:survey:mailing|mailing]] -- or that the participants receive personalized links with a serial number ([[:en:survey:url]]).

In the first questionnaire, the answers to the selection question '' AF01 '' and the open text input ''TX01_01'' are to be stored for later use. The key for storing is the subscriber ID from variable ''SERIAL'' ([[:en:results:variables]], ''[[:en:create:functions:caseserial]]'').

<code php>
$key = caseSerial();
$data = array(
  value('AF01', 'free'),
  value('TX01_01')
);
dbSet($key, $data);
</code>

In the second questionnaire, these data are then retrieved again by using ''dbGet()'' and are written in placeholders using ''replace()'', which can then be used in question/item texts:


<code php>
$key = caseSerial();
$data = dbGet($key);
replace('%auswahl%', $data[0]);
replace('%texteingabe%', $data[1]);
</code>

**Tip:** To understand the PHP code, the chapter [[:en:create:array]] is usefull.

**Tip:** If you would like to use the database for content in the survey project, simply make a prefix to the key. Replace the line with ''$key='' in both codes ...

<code php>
$key = 'DT-'.caseSerial();
</code>