Online Book Reader

Home Category

HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [173]

By Root 1532 0

value = “change color”

onclick = “changeColor()” />

The select object’s default behavior is to provide a drop-down list. The first element on the list is displayed, but when the user clicks the list, the other options appear.

A select object that the code refers to should have an id field.

In this and most examples in this chapter, I add CSS styling to clean up each form. Be sure to look over the styles if you want to see how I did it. Note also that I’m only showing the HTML right now. The entire code listing also includes JavaScript code, which I describe in the next section.

The other element in the form is a button. When the user clicks the button, the changeColor() function is triggered.

Because the only element in this form is the select object, you may want to change the background color immediately without requiring a button click. You can do so by adding an event handler directly onto the select object:

multiple = “multiple”

size = “10”>

Return Main Page Previous Page Next Page

®Online Book Reader