Enumeration Attributes

Let’s learn about enumeration attributes.

We'll cover the following

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.

Taking inputs

To allow 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. The enumeration labels would be used as the text content of its option elements. In contrast, the enumeration indexes would be used as their values. We have to distinguish between single-valued and multi-valued enumeration attributes. In 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".

Below is a simple example that shows how enumeration values can be displayed using a drop-down list:

Get hands-on with 1400+ tech skills courses.