PDA

View Full Version : :: changing a select option'sbgColor? ::


babelfish
05-15-2003, 02:19 PM
HI PEEPS, long time no see!

ok i have this script:

function addVars() {
var f = window.document.listings;
if (pageVars==0) {
selectOption(f.package,package);
selectOption(f.zone,zone);
selectOption(f.doctype,doctype);
selectOption(f.company,company);

}
}

this adds some stuff into select boxes whilst reading the URL of the page. NOW, i want the selected item to have a diff colour BG - any ideas?

i thought of something like: window.document.listings.package.selectedIndex[0]bgColor='red'

dont work tho :( any ideas?

jkd
05-15-2003, 02:28 PM
Assume "select" is a reference to the select box:

select.options[select.selectedIndex].style.backgroundColor="blue";


In Mozilla, the forms.css file uses this:

option:checked {
background-color: Highlight ! important;
color: HighlightText ! important;
}


Which implies at least in Mozilla you can use simple CSS to achieve the same thing.

babelfish
05-15-2003, 02:57 PM
thx m8 :)

actually i had to change a little bit as i hadnt explained myself very well!

f.company.options[f.company.selectedIndex].style.backgroundColor="#FFE9E9" works fine

im not interested in moz as this is for an IE only cd that is being produced to be sent

babelfish
05-15-2003, 03:06 PM
is there a way in IE5 tho that can also make the text in the dropdown bold?

im not sure if this is supported?!

jkd
05-15-2003, 06:08 PM
.style.fontWeight="bold"

babelfish
05-16-2003, 08:55 AM
thanks!