Can I have a onclick event on a option tag that changes the background of that option? If so, how do I do it? Thanks![]()
Can I have a onclick event on a option tag that changes the background of that option? If so, how do I do it? Thanks![]()
I believe the CSS background property for option elements isn't supported by all browsers. I remember testing this recently... It works in Firefox 3.0 for sure, but I'm pretty sure the property is ignored in all version of Internet Explorer.
hosdank (08-27-2008)
hosdank (08-27-2008)
Yeah, but the thing is I want all the other backgrounds to change back to what they were. Thanks anyway![]()
Yes I thought you might.
Code:<select onchange="setOptionColour(this,'#0f0')"> ........ <script type="text/javascript"> function setOptionColour(box, clr) { for(var i=0, len=box.options.length; i<len; i++) box.options[i].style.backgroundColor=(i==box.selectedIndex)?clr:""; } </script>
hosdank (08-27-2008)
Thanks so much![]()
But if you check the display of a background-color based options in a select list through Firefox and IE, you'll get two different things
You can use the .select() object to select text in a textfield, jsut for later use.
-magicyte
Bookmarks