~~NOTOC~~

====== textlink() ======

''string **textlink**(string //textID//, string //label//, [int //width//, int //height//])''

It is equally possible to display text (e.g. a lengthy label) in a new window (pop-up), instead of directly in the questionnaire. The text will appear in the same layout as it would in the questionnaire.

  * //textID//\\ ID of the text element to be shown in the pop-up window. 
  * //label//\\  Label of the hyperlink that opens the pop-up.
  * //width//\\  Width of the pop-up window in [[:en:glossary#pixel|pixels]] (optional).
  * //height//\\ Height of the pop-up window in pixels (optional). 

===== Tips =====

**Note:** This function only creates the link. You still have to place the link in the questionnaire using ''[[:en:create:functions:text|html()]]'' or [[:en:create:placeholders|placeholders]].

**Note:** Only users of the questionnaire can access the text by clicking on the link generated. 

**Tip:** The size of the new window can be specified optionally. It often makes sense to keep the window small so the questionnaire can still be seen in the background. If no size is specified, the default size of 600 × 500 pixels is used. 

**Tip:** If you do not want to open a separate window in the questionnaire when displaying a short amount of text -- who knows if the participant can find their way back to the questionnaire afterwards -- then read the following chapter: [[:en:create:popup|Click to Get Information]]


===== Example 1 =====

For the following example, a new text element with the ID "explanation" must be created first of all in **Text Elements and Labels**. After this, the following PHP code is put on a page in the questionnaire. 


<code php>
// Save the HTML code for the link in the PHP variable $link 
$link = textlink('explanation', 'here');
// Display the link in the questionnaire
html('<p>Please click '.$link.'</p>');
</code>

The following PHP code delivers the same result -- it's just a little bit more complex. 

<code php>
html('<p>Please click '.textlink('explanation', 'here').'</p>');
</code>

===== Example 2 =====

Often, it is simpler to place the link in the questionnaire using placeholders. The following PHP code is put above a question that uses the placeholder ''%link%'' in the question title. 


<code php>
replace('%link%', textlink('explanation', 'here'), 'html');
</code>

===== Example 3 =====

The following PHP code opens a pop-up window with a size of 640 × 400 pixels. 

<code php>
$link = textlink('explanation', 'statement', 640, 400);
html('<p>If necessary, please read '.$link.'</p>');
</code>