473,625 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

changing background color of multiple select

I have two multiple select inputs. Initially the first contains a bunch of
items and the second is empty. Using a common method, I move items back and
forth by double clicking on them.

This portion works perfectly, but I would also like to change the background
color of the select element with the current focus.

I have defined the following classes:

..selected {
background: #C0FFFF
}
..deselected {
background: #FFFFFF
}

Using the following function below I am able to shift the background color
of rows containing content, but the color of the empty rows remain the
"selected" color. How can this effect be achieved for all rows, whether they
contain content or not?

Thanks!
May 3 '06 #1
8 3909
[Repost including function.]

I have two multiple select inputs. Initially the first contains a bunch
ofitems and the second is empty. Using a common method, I move items back
andforth by double clicking on them.

This portion works perfectly, but I would also like to change the background
color of the select element with the current focus.

I have defined the following classes:

..selected {
background: #C0FFFF
}
..deselected {
background: #FFFFFF
}

Using the following function below I am able to shift the background color
of rows containing content, but the color of the empty rows remain the
"selected" color. How can this effect be achieved for all rows, whether they
contain content or not?

Thanks!

-----------------------------------------------------------

function changeBackgroun d(obj,theSelect ) {
for (var i=1; i<obj.length; i++) {
obj[i].className = 'deselected';
}
obj[theSelect].className = 'selected';
}
May 3 '06 #2
Bosconian said the following on 5/3/2006 12:36 PM:
[Repost including function.]

I have two multiple select inputs. Initially the first contains a bunch
ofitems and the second is empty. Using a common method, I move items back
andforth by double clicking on them.

This portion works perfectly, but I would also like to change the background
color of the select element with the current focus.

I have defined the following classes:

..selected {
background: #C0FFFF
}
..deselected {
background: #FFFFFF
}

Using the following function below I am able to shift the background color
of rows containing content, but the color of the empty rows remain the
"selected" color. How can this effect be achieved for all rows, whether they
contain content or not?


Rather than changing the background of each individual option, change
the background color of the select itself. Thats if I am reading what
you wrote correctly.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 3 '06 #3
> Rather than changing the background of each individual option, change
the background color of the select itself. Thats if I am reading what
you wrote correctly.


Yes, that's correct. I was unsure of the syntax.
May 3 '06 #4
Bosconian said the following on 5/3/2006 1:12 PM:
Rather than changing the background of each individual option, change
the background color of the select itself. Thats if I am reading what
you wrote correctly.


Yes, that's correct. I was unsure of the syntax.


onblur="this.cl assName = 'deselected'"
onfocus="this.c lassName = 'selected'"

in both select lists.

IE still isn't going to get along with you. It won't change the "empty"
lines background color (even though it will set them initially).

What you could do to get around that is to change the size of the select
list every time something is added or removed.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 3 '06 #5
"Randy Webb" <Hi************ @aol.com> wrote in message
news:Hd******** *************** *******@comcast .com...
Bosconian said the following on 5/3/2006 1:12 PM:
Rather than changing the background of each individual option, change
the background color of the select itself. Thats if I am reading what
you wrote correctly.


Yes, that's correct. I was unsure of the syntax.


onblur="this.cl assName = 'deselected'"
onfocus="this.c lassName = 'selected'"

in both select lists.

IE still isn't going to get along with you. It won't change the "empty"
lines background color (even though it will set them initially).

What you could do to get around that is to change the size of the select
list every time something is added or removed.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -

http://www.JavascriptToolbox.com/bestpractices/

Randy,

Thanks for your reply.

I've been experimenting since my last post and have discovered just that: IE
will change the background color of all "empty" options until a single
option is added.

I would prefer not to dynamically change the size of the multiple-selects so
what about changing the border style instead?
May 3 '06 #6
"Randy Webb" <Hi************ @aol.com> wrote in message
news:Hd******** *************** *******@comcast .com...
Bosconian said the following on 5/3/2006 1:12 PM:
Rather than changing the background of each individual option, change
the background color of the select itself. Thats if I am reading what
you wrote correctly.


Yes, that's correct. I was unsure of the syntax.


onblur="this.cl assName = 'deselected'"
onfocus="this.c lassName = 'selected'"

in both select lists.

IE still isn't going to get along with you. It won't change the "empty"
lines background color (even though it will set them initially).

What you could do to get around that is to change the size of the select
list every time something is added or removed.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -

http://www.JavascriptToolbox.com/bestpractices/

So switching the color shift from background to border works great in
Firefox, but not IE.

onfocus="this.c lassName = 'selected'"

..selected {
border: 2px solid #FF0000;
}
..deselected {
border: 2px solid #FFFFFF;
}

Is there another cross-browser compatible way to change the border color of
a multiple-select other than resorting to something like

onfocus="this.s tyle.borderColo r='#FF0000'"

I'd prefer to define all my styles as classes.

May 3 '06 #7
"Bosconian" <bo*******@plan etx.com> wrote in message
news:R4******** *************** *******@comcast .com...
"Randy Webb" <Hi************ @aol.com> wrote in message
news:Hd******** *************** *******@comcast .com...
Bosconian said the following on 5/3/2006 1:12 PM:
> Rather than changing the background of each individual option, change
> the background color of the select itself. Thats if I am reading what
> you wrote correctly.

Yes, that's correct. I was unsure of the syntax.
onblur="this.cl assName = 'deselected'"
onfocus="this.c lassName = 'selected'"

in both select lists.

IE still isn't going to get along with you. It won't change the "empty"
lines background color (even though it will set them initially).

What you could do to get around that is to change the size of the select
list every time something is added or removed.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -

http://www.JavascriptToolbox.com/bestpractices/

So switching the color shift from background to border works great in
Firefox, but not IE.

onfocus="this.c lassName = 'selected'"

.selected {
border: 2px solid #FF0000;
}
.deselected {
border: 2px solid #FFFFFF;
}

Is there another cross-browser compatible way to change the border color

of a multiple-select other than resorting to something like

onfocus="this.s tyle.borderColo r='#FF0000'"

I'd prefer to define all my styles as classes.

I've discovered that likewise the previously defined border styles work just
fine in Firefox, but not IE. Any suggestions for a workaround?
May 3 '06 #8
"Bosconian" <bo*******@plan etx.com> wrote in message
news:09******** *************** *******@comcast .com...
"Bosconian" <bo*******@plan etx.com> wrote in message
news:R4******** *************** *******@comcast .com...
"Randy Webb" <Hi************ @aol.com> wrote in message
news:Hd******** *************** *******@comcast .com...
Bosconian said the following on 5/3/2006 1:12 PM:
>> Rather than changing the background of each individual option, change >> the background color of the select itself. Thats if I am reading what >> you wrote correctly.
>
> Yes, that's correct. I was unsure of the syntax.
>
>

onblur="this.cl assName = 'deselected'"
onfocus="this.c lassName = 'selected'"

in both select lists.

IE still isn't going to get along with you. It won't change the "empty" lines background color (even though it will set them initially).

What you could do to get around that is to change the size of the select list every time something is added or removed.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

So switching the color shift from background to border works great in
Firefox, but not IE.

onfocus="this.c lassName = 'selected'"

.selected {
border: 2px solid #FF0000;
}
.deselected {
border: 2px solid #FFFFFF;
}

Is there another cross-browser compatible way to change the border color

of
a multiple-select other than resorting to something like

onfocus="this.s tyle.borderColo r='#FF0000'"

I'd prefer to define all my styles as classes.

I've discovered that likewise the previously defined border styles work

just fine in Firefox, but not IE. Any suggestions for a workaround?


I'm now thinking that it will be easier to simply wrap each select in a div
and change the border color & size as desired.
May 4 '06 #9

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

Similar topics

14
5195
by: Holden Caulfield | last post by:
Hi there, for IE 5+ I need to be able to change certain TD tags´ background colors, and can´t figure out how to do it... For instance, in a table with 25 cells, somewhere between 5 or 10 will need the bgcolor to change at the same time when a user clicks a button. Right now only one changes when I use something like this... document.getElementById(´cellchange´).style.backgroundColor = "FFFFFF" ** (Note, this is not the EXACT code, I...
4
1964
by: david.graham18 | last post by:
Hi I spotted some nice code to change the background colour of a web page to one of four different colours at random but I can't find it now! The method was to select a number at random from 1 to 4 by using the rnd() function and then dividing by modulus 4. The result was then used to select a cell in a 4 cell array which was holding a different colour in each cell of the array. I would like to have this code but lack the knowledge to...
0
1316
by: Tom | last post by:
Hi I have a ListBox control of my asp.net web page. I want to set the value of the style property of the ListItem to a specific background color. I have tried this but no success: //li is the ListItem object li.Attributes.CssStyle.Add("BACKGROUND-COLOR:","blue");
12
4526
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in another forum from Peter Huang that said that an id="bg" as follows... <body MS_POSITIONING="GridLayout" runat="server" id="bg"> then we could do the following in our codebehind file....
7
8722
by: Glenn Hanna | last post by:
Hi, Can someone tell me how to change the background color of a web page though C#? I've tried various things that I have found on the web written in VB but I haven't had much luck with them. Thank you, Glenn
2
1839
by: Bosconian | last post by:
I have two multiple select inputs. Initially the first contains a bunch of items and the second is empty. Using a common method, I move items back and forth by double clicking on them. This portion works perfectly, but I would also like to change the background color of the select element with the current focus. I have defined the following classes: ..selected {
13
3016
by: amykimber | last post by:
Hi all, I know I'm doign something really daft, but I can't get this to work... I have a form with a bunch of inputs called ship_owner - why the ? Because I'm submitting this page though php and the put the data into an array in the post.... anywhat. I have a link <a href="javascript:change_class()" >Block mode</a> to
1
4812
by: 32Alpha | last post by:
Hi, first post here. First off, this IS a homework assignment for an operating systems class, but the question isn't "how do i do the assignment" but "why is my particular implementation not working". I've searched the forums here, but could not find anything particular to my problem, Googling and the linux manual pages haven't been much help either. What the program is supposed to do is create a very simple shell (that sits atop the...
5
5243
by: jeddiki | last post by:
I want to change the default background color of my select box. Here is the problem: Link to form with color select Notice in the color selector, the background color that I have given it it the option statement changes on hover to a blue/gray. Instead of background color change I would like the text to BOLD. So on hovering over green, the text "green" goes green (bold) but
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.