- How do you get the value of the selected option in a select box or a reference to the selected option?
- How do you get the selected options in a select box that allows multiple selections?
- What's the difference between the selectedIndex and selected properties? Which should you use?
- How do you add and remove options in a select box?
- Can you dynamically change the options in a select box based on the selection in another?
Basic Facts about Select Boxes
Form select boxes display a list of options, either as a drop-down menu or a list box. By default, select boxes only display one option at a time and allow selection of one option at a time. But a
size attribute can be included to specify how many options will be visible, and a
multiple attribute allows selection of more than one option in the list. The
type property for a select object will either be
select-multiple depending upon the presence or absence of the
multiple attribute, which is a boolean attribute.
selected properties as well as the
onchange event. The examples listed above demonstrate and describe the properties, and an example pizza order form demonstrates onchange event handling for both
select-multiple type select lists.