Demonstrates select object used as a multi-line list box : Option Select ComboBox « Form Control « JavaScript DHTML






Demonstrates select object used as a multi-line list box

   
<html>
<head>
<script>
function changeColor(){
  var theSelect = document.myForm.selColor;
  var selectedOne = theSelect[theSelect.selectedIndex];
  var theColor = selectedOne.value;
  document.bgColor = theColor;

  var colorList = "";
  var i = 0;

  for (i = 0; i < theSelect.length; i++){
    selectedOne = theSelect.options[i];
    if (selectedOne.selected == true){
      colorList += selectedOne.value + "\n";
    }
  }
  document.myForm.txtOutput.value = colorList;
}
</script>
</head>
<body>
Color Chooser
<form name = "myForm">
<select name = selColor multiple size = 3>
  <option value = red>red</option>
  <option value = orange>orange</option>
  <option value = yellow>yellow</option>
</select>
<input type = "button"
       value = "change color"
       onClick = "changeColor()">
<textarea name = txtOutput
          rows = 10
          cols = 40>
</textarea>
</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.Grouped selection control on change event
18.Change background
19.Changing Select Element Content (two Combobox)
20.Drop-down Redirect - No Submit button
21.Drop-down Redirect - Submit
22.Dropdown list (combobox) in a form
23.dropdown list (combobox) in form 2
24.Disable or enable an option
25.Disable and enable a dropdown list (combobox)
26.Return the name of the form that contains dropdown list (combobox)
27.Number of options in the dropdown list(Combobox)
28.Change the size of a dropdown list (ComboBox)
29.Select multiple options in a dropdown list (option)
30.Return the selected option as text in option
31.Return the selected option as a number
32.Change the option text
33.Remove an option from a dropdown list (combobox)
34.Methods and Properties of the Select Object
35.Properties of the Option Object
36. Using the Location object to change another frame's URL
37.Using a Summary Form to Support Local Processing
38.Navigating with a SELECT Object
39.Using the selectedIndex Property
40. Modifying OPTGROUP Element Labels
41.Using the options[index].text Property
42. Using the options[index].value Property
43.Triggering a Color Change from a Pop-Up Menu
44.Modifying SELECT Options
45.Modifying SELECT Options (IE4+)
46.Modifying SELECT Options (NN6+)
47.Selecting an Option Using JavaScript
48.Linked ComboBox (option) Country =- province
49.ComboBox set value to TextField
50.Menu(Option) Generator
51.URL Option ComboBox
52.Show Selected Option items
53.Click button to navigate to selected url from form select control
54.Set the select control value
55.Add or remove options from select form control
56.Get changed selection from form select