Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision |
en:create:functions:replace [15.01.2015 20:04] – [replace()] alexander.ritter | en:create:functions:replace [28.11.2015 17:24] – admin |
---|
''void **replace**(string //placeholder//, string //content//, [string //type//])'' | ''void **replace**(string //placeholder//, string //content//, [string //type//])'' |
| |
* //placeholder//\\ The placeholder subsequently used. A placeholder is put between percentage signs (''%''). Please take the [[:en:create:placeholders#rules_for_customized_placeholders|rules for customized placeholders]] into consideration. | * //placeholder//\\ The placeholder subsequently used. A placeholder is put between percentage signs (''%''). Please take the [[:en:create:placeholders#customized_placeholder_rules|rules for customized placeholders]] into consideration. |
* //content//\\ Normally the text used instead of the placeholder. Depending on the type specified afterwards, a variable ID could also be stated here. | * //content//\\ Normally the text used instead of the placeholder. Depending on the type specified afterwards, a variable ID could also be stated here. |
* //type// | * //type// |
* '''text''' -- (default) The //content// is read as plain text. | * '''text''' -- (default) The //content// is read as plain text. |
* '''html''' -- The //content// is read as HTML code. HTML special characters (such as ''<'' or ''>'') are tranferred unmasked into the questionnaire's source code. | * '''html''' -- The //content// is read as HTML code. HTML special characters (such as ''<'' or ''>'') are tranferred unmasked into the questionnaire's source code. |
* '''response''' A variable ID is specified as the //content//. The placeholder should be replaced with the response of the participant to this variable. The way the response is determined is equivalent to ''[[:en:create:functions:value|value(..., 'text')]]''. **Note:** The participant must first transmit the response to the server with "Next" before it can be called up with PHP code. Therefore, ''[[:en:create:functions:replace(..., 'response')]]'' must not be used on the same page as the question; on the following page at the earliest. | * '''response''' A variable ID is specified as the //content//. The placeholder should be replaced with the response of the participant to this variable. The way the response is determined is equivalent to ''[[:en:create:functions:value|value(..., 'text')]]''. **Note:** The participant must first transmit the response to the server with "Next" before it can be called up with PHP code. Therefore, ''replace(..., 'response')'' must not be used on the same page as the question; on the following page at the earliest. |
| * '''special''' -- Use one of the following IDs as //content// to employ dynamic data for the placeholder: |
| * '''qn-''' -- The last number used for a question (e.g., to refer to the previous question in instructions). |
| * '''qn+''' -- Create a new question number (e.g., to add a number to [[:en:create:inputs-custom|custom form inputs]]). |
| |
| |
| |
// Replace %response% with the response of the participant to the single selection question AB02 | // Replace %response% with the response of the participant to the single selection question AB02 |
replace('%response%', 'AB02', 'response'); | replace('%response%', 'AB02', 'response'); |
| |
| // Replace %number% by a new question number |
| replace('%number%', 'qn+', 'special'); |
| html('<div class="title">%number%. Please select the ...</div>'); |
</code> | </code> |