devxlogo

Present Lists Using the SELECT Control

Present Lists Using the SELECT Control

You can use the SELECT control to present a predefined list to the user. The SELECT control is useful for quickly selecting one or more items from a predefined or dynamically generated list from the database. You can implement the SELECT control in different ways, including a drop-down list, a list box, or a multi-select list box. These use a combination of SIZE and MULTIPLE attributes.

To populate the control, you use the OPTION object. To get hold of the selected value(s), you need the reference of the control and the selected option. To retrieve the selected value, you use the SelectedIndex property with the options collection to identify the particular item.

In order to retrieve the selected values from a multi-select list, you need to iterate through all the options. The selected property can be queried to determine if the option is selected. If so, you can use the current index of the iteration to acquire the text or value of the item.

When a multi-select list is submitted, the items are sent as a comma-delimited list. If a VALUE attribute is not provided as an option, the TEXT attribute is sent instead.

Drop-down list

 SELECT ID="CityList">

List box

 SELECT ID="CityList" SIZE="2">

Multi-select list box

 SELECT ID="CityList" SIZE="3" MULTIPLE>
See also  Monetize TikTok For Your Business
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist