$Web_Sels

From m204wiki
Jump to navigation Jump to search

Build select options from delimited list of strings, selected is string


$Web_Sels inserts into the Web output stream the options list of an HTML <select> element. The options list is taken from two arguments which are delimited lists of strings, and the selected option (that is, the one that is highlighted on the HTML page) is specified by a character string. An overview of the $Web_Sel* functions is provided in $Web_Selp.

$Web_Sels takes four arguments and always returns null, unless an error occurs, in which case the current User Language request is cancelled. It is a callable $function.

Syntax

%rc = $Web_Sels(delimited_vals, [delimited_descrs], [selected_value], [option_keywords])

Syntax terms

delimited_vals A string containing a delimited list of strings which are the values for the options list. The first character of this argument is the delimiter that separates the values. The string should not contain a trailing delimiter unless you want the null string as the final value, which is unlikely. This is a required argument.
delimited_descrs A string containing a delimited list of strings which are the descriptions for the options list. The first character of this argument is the delimiter that separates the descriptions. The string should not contain a trailing delimiter unless you want the null string as the final description, which is unlikely.

This is an optional argument; if omitted, the description of each generated option is identical to its value.

selected_value A string which, if equal to one of the values in the options list, specifies the item which is selected in the displayed options list; this does not allow multiple item selection in a <select multiple> element.

This an optional argument. If this argument is omitted, or if the string is not equal to the value of any of the options in the global select element, then none of the <option> elements in the list contain the selected attribute.

As explained in $Web_Selp, the default selected option depends on the type of <select> element: <select multiple> has no default; for non-multiple, the first item in the options list is the default selected element.

option_keywords This optional argument is a string of blank-separated keywords specifying special processing for this $function; it can contain any of the following:
NOENDSEL Don't end list of options with </select>
NOENDS Synonym for NOENDSEL
ENDOPT End each option with </option>

Return codes

Code Meaning
null The operation completed successfully.
Any error results in cancellation of the User Language request.

Examples

  1. The following statement places a <select> element into the web response output, containing the Italian days of the week; the middle day of the week is selected:

    %RC = $Web_Sels('/Domenica/Lunedi/Martedi' WITH - '/Mercoledi/Giovedi/Venerdi/Sabato', - '/DN0/DN1/DN2/DN3/DN4/DN5/DN6', 'DN3')

  2. See $Web_Selp for an extended example using other $Web_Sel* functions.