By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

Why doesn' t his work?

P: n/a
Trying to set the background colour for individual drop down items using
JS -

////////////////////////////////////////////////////////////////////////////
//////////////////////
var ctrl = getElementByID('busresid');

ctrl.options[2].style="background-color:#FF0000";
////////////////////////////////////////////////////////////////////////////
//////////////////////

in jsp page can set it no problem like -

////////////////////////////////////////////////////////////////////////////
//////////////////////
<select id='busresid''>
<option style="background-color:#FF0000">Red</option>
<option style="background-color:#FFFF33 ">Amber</option>
<option style="background-color:#00FF00 ">Green</option>
</select>

////////////////////////////////////////////////////////////////////////////
//////////////////////

any ideas?

thanks

harry
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"harry" <a@abc.com> wrote in message
news:5H*********************@news-text.cableinet.net...
Trying to set the background colour for individual drop down items using
JS -

var ctrl = getElementByID('busresid');

ctrl.options[2].style="background-color:#FF0000";

in jsp page can set it no problem like -

<select id='busresid''>
<option style="background-color:#FF0000">Red</option>
<option style="background-color:#FFFF33 ">Amber</option>
<option style="background-color:#00FF00 ">Green</option>
</select>

<snipped a zillion slashes />

the style attribute of an element is not a text-node, but an object:

ctrl.options[2].style.backgroundColor = "#ff0000";

--
Dag
5826'15.9" N 00846'45.5" E
Jul 23 '05 #2

P: n/a
Thanks, works fine now!

"Dag Sunde" <ds@orion.no-way> wrote in message
news:NU**********************@juliett.dax.net...
"harry" <a@abc.com> wrote in message
news:5H*********************@news-text.cableinet.net...
Trying to set the background colour for individual drop down items using
JS -

var ctrl = getElementByID('busresid');

ctrl.options[2].style="background-color:#FF0000";

in jsp page can set it no problem like -

<select id='busresid''>
<option style="background-color:#FF0000">Red</option>
<option style="background-color:#FFFF33 ">Amber</option>
<option style="background-color:#00FF00 ">Green</option>
</select>

<snipped a zillion slashes />

the style attribute of an element is not a text-node, but an object:

ctrl.options[2].style.backgroundColor = "#ff0000";

--
Dag
5826'15.9" N 00846'45.5" E

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.