473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

read style of selectedIndex

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>
Jul 20 '05 #1
2 3615

"Bart Van der Donck" <ba**@nijlen.com> schreef in bericht
news:b5**************************@posting.google.c om...
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
Jul 20 '05 #2
> oS=document.forms[0].r
a=oS.options[oS.selectedIndex].style.color


Thanks Freddy that works great!
Bart
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Randell D. | last post by:
Whats wrong with my sample script below? All I want to do is confirm that my form data is in my environment (basically, I'm writing a script that will check that some form fields have a value, and...
5
by: Ben | last post by:
I have a form for data entry which is in a table. I have a select box to enter a customer name, which takes it's options from the customer database. I have a button to add a new customer. What I...
4
by: Mantova | last post by:
Maybe it's simple, but I can't get it to work. I'm originally a webdeveloper, and just started to work on a C# windows application. I want a list, something similar to a <select><option> object,...
16
by: Mike L | last post by:
This is for a Win form. My combo box DropDownStyle is set to simple. When the user types in a 3 character string in the combo box, the closest item in the collection is shown, right below where...
3
by: Nathan Sokalski | last post by:
I am working on a simple user control composed of 3 DropDownLists that will be used to select Dates. The purpose of the control is to all the user to choose a date using dropdown lists but not need...
5
by: Isha | last post by:
Hi all, I wanted to change the background color for only the first option in a select box, but following changed the background color for the whole dropdown box. <select name="alltags"...
4
by: Winston | last post by:
Where is the mistake? I want to make a simple menu. These are two pieces of two files... function ShowMenu(objeto) { is_open = document.getElementById(objeto).style.display;...
4
by: gimme_this_gimme_that | last post by:
Hi, I have an onchange method for a select box that goes something like this (the select is in a form named aForm): function page_on_change() { pageElement = aForm.my_page_id;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
0
jinu1996
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...

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.