104Part IIJavaScript Tutorialthe onclickevent handler invokes the fullName()function. (Web hosting bandwidth)

104Part IIJavaScript Tutorialthe onclickevent handler invokes the fullName()function. In that function, the first state- ment creates a shortcut reference to the form. Next, a forrepeat loop looks through all of thebuttons in the stoogesradio button group. An ifconstruction looks at the checkedprop- erty of each button. When a button is highlighted, the breakstatement bails out of the forloop, leaving the value of the iloop counter at the number where the loop broke ranks. Thealert dialog box then uses a reference to the valueproperty of the ith button so that the fullname can be displayed in the alert. Listing 9-3:Scripting a Group of Radio Objects

Select your favorite Stooge: MoeLarryCurly

The select ObjectThe most complex form control to script is the selectelement object. As you can see fromthe DOM Level 0 form object hierarchy diagram (see Figure 9-1), the selectobject is really acompound object: an object that contains an array of optionobjects. Moreover, you canestablish this object in HTML to display itself as either a pop-up list or a scrolling list thelatter configurable to accept multiple selections by users. For the sake of simplicity at thisstage, this lesson focuses on deployment as a pop-up list that allows only single selections. Some properties belong to the entire selectobject; others belong to individual optionsinside the selectobject. If your goal is to determine which item the user selects, and youwant the code to work on the widest range of browsers, you must use properties of both theselectand optionobjects.

Leave a Reply