NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_htmlselect(n) 4.99.30 naviserver "NaviServer Built-in Commands"

Name

ns_htmlselect - Build an HTML SELECT form widget from the specified data

Table Of Contents

Synopsis

Description

This command builds an HTML SELECT tag using the passed-in data. If -multi is specified, the SELECT will be generated with the MULTIPLE attribute to allow multiple options to be selected. This option also affects the SIZE attribute output for the SELECT. If -multi is specified, the SIZE attribute will be set to 5 or the number of elements in values, whichever is less. If -multi is not specified, then the SIZE attribute will be set to 5 if there are more than 25 elements in values. If there are 25 or fewer elements in values, the SIZE attribute will be omitted (equivalent to SIZE=1).

If -sort is specified, the option list of the SELECT will be sorted according to the elements of labels, or the elements of values if labels is not specified.

labels is an optional list of labels to display. If not specified, the elements of values will be used. The order and number of the labels list must match the order and number of the values list.

name specifies the NAME attribute of the SELECT statement.

values is a list of the OPTIONs for the SELECT. If labels are not specified, the values themselves will be used as the OPTION labels.

selectedData is an optional list of the OPTIONs that will be selected by default.

COMMANDS

ns_htmlselect ?-multi? ?-sort? ?-labels [arg labels]? name values ?selectedData?

EXAMPLES

 % ns_htmlselect -sort -labels {dog cat cow} "favoriteAnimal" {1 2 3} 2
 <select name='favoriteAnimal'>
 <option value="2" selected>cat
 <option value="3">cow
 <option value="1">dog
 </select>