Sunday, January 18, 2009

How to change the color of the selected item of drop downlist


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


No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.