read style of selectedIndex

  • Thread starter Bart Van der Donck
  • Start date
B

Bart Van der Donck

Hello,

I am using IE5 and have a select-box with options that have different
colors. Is there a way to read out the style attribute of the
selectedIndex (here: color)?
See simple demo script here under.

Thanks in advance,
Bart


<html>

<head>
<script>
function goz()
{
a="[MYCOLOR]"
// How can this alert box show the current color ?
alert('The selected option has color:'+a)
}
</script>
</head>

<body>
<form>
<select size=2 onDblClick="goz()" name=r>
<option value="1" style="color: red">fff
<option value="2" style="color: black">dfd
</select>
</form>
</body>

</html>
 
F

Freddy

Bart Van der Donck said:
Hello,

I am using IE5 and have a select-box with options that have different
colors. Is there a way to read out the style attribute of the
selectedIndex (here: color)?
See simple demo script here under.

Thanks in advance,
Bart


<html>

<head>
<script>
function goz()
{
a="[MYCOLOR]"

oS=document.forms[0].r
a=oS.options[oS.selectedIndex].style.color


// How can this alert box show the current color ?
alert('The selected option has color:'+a)
}
</script>
</head>

<body>
<form>
<select size=2 onDblClick="goz()" name=r>
<option value="1" style="color: red">fff
<option value="2" style="color: black">dfd
</select>
</form>
</body>

</html>

Fred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,569
Members
47,205
Latest member
KelleM857

Latest Threads

Top