[[text()]]
Translations of this page:
 

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.

  • textID
    ID of the text element
  • options
    Display options can be specified optionally. Options must be put in quotation marks (single or double) (see example). Multiple options are separated with commas as different parameters.
    • spacing=<n>
      Inserts additional spacing (<n> pixels) between the following question and the text element.
    • spacing=default
      Inserts the same amount of spacing below the text element as below a question (default spacing is set in the layout).
    • align=<left|center|right|justify>
      Aligns the content left, center, right or justified. Please take into consideration that justified text does not usually result in an attractive typeface due to a lack of hyphenation (in HTML content, &shy; can be used to separate words as required.

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.

en/create/functions/text.txt · Last modified: 04.01.2015 14:15 by alexander.ritter
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki