<html>
<head>
<title>
change the color of the selected item
</title>
<script language="javascript">
function chgColor(evt)
{
evt.options[evt.selectedIndex].style.background = 'red';
for(i=0; i< evt.options.length;i++)
{
if(i != evt.selectedIndex)
{
evt.options[i].style.background = '';
}
}
}
</script>
</head>
<body>
<select onchange="chgColor(this)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="1">5</option>
<option value="2">6</option>
<option value="3">7</option>
<option value="4">8</option>
<option value="1">9</option>
<option value="2">0</option>
</select>
</body>
Sunday, January 18, 2009
How to change the color of the selected item of drop downlist
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment