Grouped selection control on change event : Option Select ComboBox « Form Control « JavaScript DHTML






Grouped selection control on change event

   
<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> 

   
    
    
  








Related examples in the same category

1.Set select to multiple selected
2.Options in select
3.Option label
4.Option default Selected Example
5.Option selected Index Example
6.Option selected
7.Is Select a select-multiple
8.'index' Example
9.'value' Example
10.Add an option to select
11.'text' Example
12.Option selected index
13.Auto Linked Option Listbox without button
14.Triggering a Value Change from a Pop-Up Menu
15.Cycling through a Multiple-Selection List
16.Modifying optgroup Element Labels
17.Change background
18.Changing Select Element Content (two Combobox)
19.Drop-down Redirect - No Submit button
20.Drop-down Redirect - Submit
21.Dropdown list (combobox) in a form
22.dropdown list (combobox) in form 2
23.Disable or enable an option
24.Disable and enable a dropdown list (combobox)
25.Return the name of the form that contains dropdown list (combobox)
26.Number of options in the dropdown list(Combobox)
27.Change the size of a dropdown list (ComboBox)
28.Select multiple options in a dropdown list (option)
29.Return the selected option as text in option
30.Return the selected option as a number
31.Change the option text
32.Remove an option from a dropdown list (combobox)
33.Methods and Properties of the Select Object
34.Properties of the Option Object
35. Using the Location object to change another frame's URL
36.Using a Summary Form to Support Local Processing
37.Navigating with a SELECT Object
38.Using the selectedIndex Property
39. Modifying OPTGROUP Element Labels
40.Using the options[index].text Property
41. Using the options[index].value Property
42.Triggering a Color Change from a Pop-Up Menu
43.Modifying SELECT Options
44.Modifying SELECT Options (IE4+)
45.Modifying SELECT Options (NN6+)
46.Selecting an Option Using JavaScript
47.Linked ComboBox (option) Country =- province
48.ComboBox set value to TextField
49.Menu(Option) Generator
50.URL Option ComboBox
51.Show Selected Option items
52.Click button to navigate to selected url from form select control
53.Set the select control value
54.Add or remove options from select form control
55.Get changed selection from form select
56.Demonstrates select object used as a multi-line list box