Help - Search - Members - Calendar
Full Version: Which events are called?
HTMLHelp Forums > Programming > Client-side Scripting
msucimaster
I want to show a picture when an entry in a select box an entry is selected. It should be shown immediately as it is meant as a help for people to choose the right option. So I need to know which events are generated that I can use.

The selected box has multiple rows (size=4).

Can someone help me with this information?
pandy
onchange for the SELECT. The value for SELECT is the value of the chosen option.

CODE
function getOption(x)
{
   alert(x);
}


HTML
<select onchange="getOption(this.value);">
<option selected>Choose a Pet</option>
<option value="dog">Dog</option>
<option value="cat">Cat</option>
<option value="parrot">Parrot</option>
</select>


Note that the returned value is that of the value attribute, not what's visible on the page. So if the first option is chosen 'dog' not 'Dog' will be returned.
msucimaster
Thank you.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.