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