BuildOptionList
This function outputs <option>
elements for use inside <select>
, <optgroup>
or <datalist>
HTML elements.
Arguments
BuildOptionList(1,2,3,[4a,4b])
Ordinal | Type | Required | Description |
---|---|---|---|
1 | String | True | Default option value |
2 | String | True | Option value |
3 | String | True | Option name |
4a | String | True | Additional option value (see note) |
4b | String | True | Additional option name (see note) |
NOTE: Additional pairs of values and names can be appended as arguments.
Not a subscriber? Subscribe now.
Example
%%[
var @defaultRank, @optionList
set @defaultRank = AttributeValue("rank")
set @defaultRank = "4"
set @optionList = BuildOptionList(@defaultRank,"1", "Good", "2", "Better", "3", "Best", "4", "OK" )
]%%
default rank: %%=v(@defaultRank)=%%
<br>Ranking: <select name="rank">
%%=v(@optionList)=%%
</select>
Output
default rank: 4
<br>Ranking: <select name="rank">
<option value="1">Good</option>
<option value="2">Better</option>
<option value="3">Best</option>
<option value="4" selected="selected">OK</option>
</select>