====== 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 ''[[:en:create:functions:html|html()]]''. The function ''text()'' is used mainly in [[:en:create:filters|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=''\\ Inserts additional spacing ( 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=''\\ 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, ''­'' 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 [[:en:create:placeholders|placeholders]] in the texts, e.g. in order to change individual words in the questionnaire. **Tip:** Use the function ''[[:en:create:functions:textlink|textlink()]]'' in order to display a text element in a new window (as a pop-up). The function ''[[:en:create:functions:gettextelement|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 ([[:en:create:texts|Text in the Questionnaire]]). ===== Example: Randomly Select Text ===== The following example randomly displays ([[:en:create:random_urns|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 {{:button.settings.png?nolink|Display Settings}} in order to set the alignment and spacing.