Inhaltsverzeichnis

text()

void text(string textID, [string options])

Displays a text element in the questionnaire. Text elements are created in Text Elements and Labels. As a rule, it makes more sense to use text elements as content integrated into the questionnaire directly with html(). The function text() is used mainly in Filters and Conditional Questions.

Tips

Note: The use of the function text() is equivalent to dragging & dropping a text element into the questionnaire. If you display a text element using text(), make sure that it is not put on the page again by drag & drop – otherwise, it will be displayed twice.

Note: Any other attempt (e.g. with the PHP command echo) to output text directly, would not be in the questionnaire, but at the beginning of the document instead. Therefore, the commands echo or print cannot be used in PHP code.

Tip: You can also use dynamic placeholders in the texts, e.g. in order to change individual words in the questionnaire.

Tip: Use the function textlink() in order to display a text element in a new window (as a pop-up). The function getTextElement() allows you to read the content of a text element for further use in PHP code.

Tip: Format text during input with HTML or Wiki tags in order to define headings, paragraphs, bold type or word wrap (Text in the Questionnaire).

Example: Randomly Select Text

The following example randomly displays (Randomization Using Urns) the text element with the ID “stimulusA” or “stimulusB”.

urnDraw('stimulus', 'IV01');
if (value('IV01_01') == 1) {
  text('stimulusA');
} else {
  text('stimulusB');
}

Example: Spacing and Alignment

In the following example, the text element with the ID “explanation” is displayed as justified text, and the following content in the questionnaire (e.g. question AB01) has a spacing of 60 pixels.

text('explanation', 'spacing=60', 'align=justify');
question('AB01');

Tip: If necessary, spacing and alignment can be set in the text element directly.

Tip: If you have put the text element onto the questionnaire page using drag & drop, then click on the cog Display Settings in order to set the alignment and spacing.