The for loop evaluates every option in the musicType Select object. The if statement finds the option that is selected. Note that you can also determine the index of the selected option in this example by using document.musicForm.musicType.selectedIndex. The number of elements in the Select.options array. This value of this property is the same as the value of Select.length .
Examples See Option.index for an example of the length property.
Property of Option Implemented in JavaScript 1.0 Security JavaScript 1.1. This property is tainted by default. For information on data tainting, see the Client-Side JavaScript Guide . You can set the selected property at any time. The display of the associated Select object updates immediately when you set the selected property for one of its options.