An enumeration attribute is an attribute that has an enumeration as its range.
In the user interface, an output field for an enumeration attribute would display the enumeration label, rather than its internal value, the corresponding enumeration index.
For allowing user input to an enumeration attribute, we can use the UI concept of a
(drop-down) selection list, which may be implemented with an
HTML select
element, such that the enumeration labels would be used as the text
content of its option
elements, while the enumeration indexes would be used as their
values. We have to distinguish between single-valued and
multi-valued enumeration attributes. In the case of a
single-valued enumeration
attribute, we use a standard select
element. In the case of a multi-valued enumeration attribute, we use a
select
element with the HTML attribute setting multiple="multiple"
.
For both cases, an example is shown in Figure 8.3. While the single select
element for "Original
language" shows the initially selected option "---" denoting "nothing selected", the multiple
select
element "Other available languages" shows a small window displaying four of
the options that can be selected.
For usability, the multiple selection list can only be implemented with an HTML
select
element, if the number of enumeration literals does not exceed a certain
threshold (like 20), which depends on the number of options the user can see on the screen
without scrolling.
For user input to a single-valued enumeration attribute, a radio button group can be used instead of a single
selection list, if the number of enumeration literals is sufficiently small (say, not larger than
7). A radio button group is implemented with a HTML fieldset
element acting as a
container of labeled input
elements of type "radio", all having the same name, which
is normally equal to the name of the represented enumeration attribute.
For user input to a multi-valued enumeration attribute, a checkbox group can be used instead of a multiple selection
list, if the number of enumeration literals is sufficiently small (say, not larger than 7). A
checkbox group is implemented with a HTML fieldset
element acting as a container of
labeled input
elements of type "checkbox", all having the same name, which is
normally equal to the name of the represented enumeration attribute.