api:select
Version 23.0.9145
Version 23.0.9145
api:select
The api:select
keyword is similar to a switch-case block in other programming languages. Use it to create complex conditional statements. The body of api:select
can contain one or more api:case keywords and one api:default keyword.
The value in api:select
is matched with those specified in api:case
. The body of the api:case
statement contains the keywords and statements to be executed if the value specified matches the value in the api:select
keyword.
The body of the api:default
statement is only executed if none of the api:case
statements result in a match. api:default
has no parameters and can appear only once in an api:select
.
Parameters
- value: The value to compare with those specified in
api:case
statements. - attr: The attribute whose value is compared with values specified in
api:case
statements.
Control Attributes
None
Example
Set the icon depending on the company name. The api:case
elements match CompanyA
and CompanyB
in the company_name
attribute. If any occurrences are found, take the action associated with that case.
<api:select value="[company_name]">
<api:case value="CompanyA">
<img src="http://www.companya.com/favicon.ico" />
</api:case>
<api:case value="CompanyB">
<img src="http://www.companyb.com/favicon.ico" />
</api:case>
<api:default>
<img src="http://www.myhosting.com/generic.ico"/>
</api:default>
</api:select>
See Also
- api:case: Write cases for api:select.
- api:default: Write a default case for api:select.