473,563 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing the hover characteristics of select

290 Contributor
I want to change the default background color of my select box.

Here is the problem:
Link to form with color select

Notice in the color selector, the background color that I have given it
it the option statement changes on hover to a blue/gray.

Instead of background color change I would like the text to BOLD.
So on hovering over green, the text "green" goes green (bold) but
the background color stays green.

I have tried to do this with a onmouseover event but its not working.

Here is what I have:
Expand|Select|Wrap|Line Numbers
  1. <span class="select">Color: 
  2.  <select name="x_color" onChange="wrapText(document.getElementById('TheTextArea'),'[col='+this.value+']','[/col]');">
  3.  <option style = "background-color: black; color: white;" value = 'black' selected= "selected" onMouseOver="background-color: black;">black &nbsp;&nbsp;</option>
  4.  <option style = "background-color: blue;color: white;" value = 'blue' onMouseOver="background-color: blue;" >blue &nbsp;&nbsp;</option>
  5.  <option style = "background-color: red;" value = 'red' onMouseOver="background-color: red;">red &nbsp;&nbsp;</option>
  6.  <option style = "background-color: green;" value = 'green' onMouseOver="background-color: green;">green &nbsp;&nbsp;</option>
  7.  <option style = "background-color: yellow;" value = 'yellow' onMouseOver="background-color: yellow;">yellow &nbsp;&nbsp;</option>
  8.  <option style = "background-color: gray;" value = 'gray' onMouseOver="background-color: gray;">grey &nbsp;&nbsp;</option>
  9.  <option style = "background-color: white" value = 'white' onMouseOver="background-color: white;">white &nbsp;&nbsp;</option>
  10.  <option style = "background-color: brown;color: white;" value = 'brown' onMouseOver="background-color: brown;">brown &nbsp;&nbsp;</option>
  11.  <option style = "background-color: orange;" value = 'orange' onMouseOver="background-color: orange;">orange &nbsp;&nbsp;</option>
  12. </select>
  13. </span>
Does anyone know why this doesn't work and how I can fix it ?
Jan 28 '09 #1
5 5238
16,027 Recognized Expert Moderator MVP
You need to use the Style object of the element and set its backgroundColor property - see, for example, this link. Since you're using onmouseover inline, you can just use 'this' to refer to the element, e.g.
Expand|Select|Wrap|Line Numbers
  1. <option ... onmouseover="this.style.backgroundColor='green'">
Jan 28 '09 #2
290 Contributor
Unfortuately it didn't work :(

here is a link

you can see in the source code that I tried what you suggested.

Any other ideas ?
Jan 28 '09 #3
16,027 Recognized Expert Moderator MVP
I see - you want to make it bold. Then set the fontWeight property.
Jan 28 '09 #4
290 Contributor
The bold is no problem,
it is the keeping the background color stable that doesn't

Looks like its a built in property of the select entity.
Jan 28 '09 #5
16,027 Recognized Expert Moderator MVP
Yes, that's correct. If you want complete control, you'll need to create your own using DHTML.
Jan 29 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Boyd Reilly | last post by:
I have a form that has the user pick the type of question he will answer. The input field will be a text, numeric or date type. So, after the question is answered, I need to change the input statement. This resembles what I am doing: <form name="frm1"> Step 1 - Choose a File: <select name="selA" OnChange="makeinputbox;" width="200"...
by: Don G | last post by:
Within the menu for my site, I have inserted 'class="current"' within the link for the current page. So the link looks somthing link: <li><a href="index.php" class="current">Home</a></li> The css for formatting the menu links is: #menu a:hover { background-color: #E00080; color: white;
by: squidco | last post by:
I have some paragraphs on a page that I'd like have change color when the mouse is hovering over them. This declaration works great in Firefox and Safari, but doesn't do anything in IE. p:hover.review { color: #FFCC00; padding: 0px;
by: Michael Eisenstadt | last post by:
What are the coding options for client-side image size changing? I want the viewer to be able to switch between two different sizes of the same image with his/her mouse. Thanks in advance for your help. Michael Eisenstadt
by: madsgormlarsen | last post by:
Hi I am making a tab menu with css, and the tabs changes color depending on wich tab is current. 1. I could load a different css file for each tab/color. 2. I could do some inline css only for the color of the tabs. (which I would then change with trough php). 3. I could make a different class for each color, and change the class of the...
by: Nico Schuyt | last post by:
Maybe a stupid question (I'm not so familiar with javascript), but: I want to change background of a paragraph or list item on mouseover. The following code works: <p onMouseover="this.style.backgroundColor='yellow'" onMouseout="this.style.backgroundColor='white'">ppppp</p> Now I want to minimize the coding bij using a function. How do I...
by: Gerry Vandermaesen | last post by:
Hi, I'm trying out the following: CSS .className { width: 30px; height: 30px; border: 1px solid black; }
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px; margin-left: -400px; width: 800px; height: 26px"> <!-- CODE GOES HERE --> </div>
by: Toby | last post by:
I am a little new as you can tell by this post. This is my first c# window app and I made all my forms and now trying to go back and change the start up form and it is giving me errors when I change the form name that is below. And help on this would be nice.. Application.EnableVisualStyles();
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.