Grouped selection control on change event : Select « Form « JavaScript Tutorial






<html> 
<head> 
<title>Color Changer 3</title> 
<script type="text/javascript"> 

function seeColor(list) { 
    var newColor = (list.options[list.selectedIndex].value); 
    if (newColor) { 
        document.bgColor = newColor; 
    } 
} 
</script> 
</head> 
<body onload="seeColor(document.getElementById('colorsList'))"> 
<form> 
<select name="colorsList" 
id="colorsList" onchange="seeColor(this)"> 
<optgroup id="optGrp1" label="Reds"> 
<option value="#ff9999">Light Red</option> 
<option value="#ff3366">Medium Red</option> 
<option value="#ff0000">Bright Red</option> 

<option value="#660000">Dark Red</option> 
</optgroup> 
<optgroup id="optGrp2" label="Greens"> 

<option value="#ccff66">Light Green</option> 
<option value="#99ff33">Medium Green</option> 
<option value="#00ff00">Bright Green</option> 
<option value="#006600">Dark Green</option> 

</optgroup> 

<optgroup id="optGrp3" label="Blues"> 
<option value="#ccffff">Light Blue</option> 
<option value="#66ccff">Medium Blue</option> 
<option value="#0000ff">Bright Blue</option> 
<option value="#000066">Dark Blue</option> 

</optgroup> 
</select></p> 

</form> 
</body> 
</html>








10.12.Select
10.12.1.Select
10.12.2.Select.blur()
10.12.3.Select.focus()
10.12.4.Select.form
10.12.5.Select.handleEvent()
10.12.6.Select.length
10.12.7.Select.name
10.12.8.Select.onBlur
10.12.9.Select.onChange
10.12.10.Select.onFocus
10.12.11.Select.options
10.12.12.Select.options.length
10.12.13.Select.options.selectedIndex
10.12.14.Select.options.value
10.12.15.Select.selectedIndex
10.12.16.Select.type
10.12.17.Triggering a Value Change from a Pop-Up Menu
10.12.18.Grouped selection control on change event