C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Change DropDownList's SelectedText colour using JavaScript


Posted Date: 02 Jul 2009    Resource Type: Code Snippets    Category: Javascript
Author: UltimateRenganMember Level: Diamond    
Rating: 1 out of 5Points: 2



The following sample code can be used to display the selected text with colors.

The example is built around a DropDownList element in a HTML page. The following is a function written in javascript that can be called on occurrence of certain events, particularly the selectedindexchange event for the dropdown list.


function ColorChange()
{
var ddl=document.getElementById("dropdown").value;
var e = document.getElementById("dropdown");
var strText = e.options[e.selectedIndex].text;
e.options[e.selectedIndex].style.color = "red"
if (strText=="c")
{
//Particular text will dispay with pink color
e.options[e.selectedIndex].style.color = "pink";
}
else
{
//selected text will display with RED Color
e.options[e.selectedIndex].style.color="red";

}
}






Responses

Author: N.Gokulakrishnan    02 Jul 2009Member Level: Bronze   Points : 1
The above code Already exist lot of Dot Net Web Sites..

Dont Post silly type of Code's Here After..


Author: UltimateRengan    02 Jul 2009Member Level: Diamond   Points : 1
Gokul,

Lots of sites have this code so why you came here,its because this site is more good one.

If you are not having guts to put resources means, go eat bun and sleep.Dont put these kind of silly messages and spoil the forum. or else you will throw out.

Regards
Thala-fan


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Change DropDownList's SelectedText colour using JavaScript  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: JavaScript: Display the Local date
Previous Resource: Changing Back Ground color of the Page
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use