ITSE 1411 Beginning Web
JS Form Selection List Chapter 5 Discussion
Discussion
- Selection Lists
- The select element creates a selection list with options from which to choose.
- Options are created using the option element.
- The selection list can display as a list of choices or as a drop-down menu (with or without a scroll bar).
- The selection list may use the multiple attribute to allow the user to select more than one option.
- The selected attribute indicates when an option is selected.
- When the selectedIndex property contains a value of -1, no option is selected.
- Adding Options to a Selection List
- The add() method does not work consistently across browsers. Therefore, to add anew option to a selection list,
use the Option() constructor the same way you use the Array() constructor to create an array.
- Removing Options from a Selection List
- To remove a single option from a selection list, use the remove() method of the Select object. The remaining list
will reorder.
- To remove all options from a selection list, set the length to 0.
- Changing Options in a Selection List
- To change an option in a selection list, assign new values to the option's value and text properties.