473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change color of <select>?

Hello all,

I need to change the colour of my text. For the paragraph I do
document.fgColo r ="blue" ;
but how do I do this for the select tags?
....and I prefer it to apply to all select tags
Tia.
Sep 27 '08 #1
4 6083
SAM
Le 9/27/08 2:24 AM, html a écrit :
Hello all,

I need to change the colour of my text. For the paragraph I do
document.fgColo r ="blue" ;
prefer
JS :
document.getEle mentById('P_1') .style.backgrou nd = 'skyblue';
HTML :
<p id="P_1"blah </p>

but how do I do this for the select tags?
<select style="backgrou nd: orange">
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
...and I prefer it to apply to all select tags
<style type="text/css">
select { background: yellow; border: 2px solid orange; }
option { background: #ffc }
p { background: #ddd; }
#P_1 { background: azure; color: blue; text-align: justify }
</style>
<p>
<select>
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
</p>
<p id="P_1"re blah </p>

<http://www.w3.org/TR/CSS21/indexlist.html>

--
sm
Sep 27 '08 #2
Hello all,

I need to change the colour of my text. For the paragraph I do
document.fgColo r ="blue" ;

prefer
JS :
document.getEle mentById('P_1') .style.backgrou nd = 'skyblue';
HTML :
<p id="P_1"blah </p>

but how do I do this for the select tags?

<select style="backgrou nd: orange">
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
...and I prefer it to apply to all select tags

<style type="text/css">
select { background: yellow; border: 2px solid orange; }
option { background: #ffc }
p { background: #ddd; }
#P_1 { background: azure; color: blue; text-align: justify }
</style>
<p>
<select>
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
</p>
<p id="P_1"re blah </p>

<http://www.w3.org/TR/CSS21/indexlist.html>
Thank you, what I need is a little different.

First of all, it is interesting that document.fgcolo r propagates into
paragraphs but not into select elements, any idea why?

Second, I want to be able to change the colour of the select
tags as a response to a click on a button, so how do I assign
to all select tags a colour in script (as opposed to in style sheet/tag)?
Tia
Sep 27 '08 #3
html wrote:
>>Hello all,

I need to change the colour of my text. For the paragraph I do
document.fgCo lor ="blue" ;
prefer
JS :
document.getEl ementById('P_1' ).style.backgro und = 'skyblue';
HTML :
<p id="P_1"blah </p>

>>but how do I do this for the select tags?
<select style="backgrou nd: orange">
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
>>...and I prefer it to apply to all select tags
<style type="text/css">
select { background: yellow; border: 2px solid orange; }
option { background: #ffc }
p { background: #ddd; }
#P_1 { background: azure; color: blue; text-align: justify }
</style>
<p>
<select>
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
</p>
<p id="P_1"re blah </p>

<http://www.w3.org/TR/CSS21/indexlist.html>

Thank you, what I need is a little different.

First of all, it is interesting that document.fgcolo r propagates into
paragraphs but not into select elements, any idea why?
It does not do that.

It only looks like it does that. Default background color is transparent.
Second, I want to be able to change the colour of the select
tags as a response to a click on a button, so how do I assign
to all select tags a colour in script (as opposed to in style sheet/tag)?
Change a class selector in an element above them. For example, add a
class "detonate" to body.

<style type="text/css">
..detonated select {
background: chartreuse;
}
</style>

using:

<button onclick="docume nt.body.classNa me='detonated'" >detonate</button>
Garrett
Tia

Sep 27 '08 #4
html wrote:
>>Hello all,

I need to change the colour of my text. For the paragraph I do
document.fgCo lor ="blue" ;
prefer
JS :
document.getEl ementById('P_1' ).style.backgro und = 'skyblue';
HTML :
<p id="P_1"blah </p>

>>but how do I do this for the select tags?
<select style="backgrou nd: orange">
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
>>...and I prefer it to apply to all select tags
<style type="text/css">
select { background: yellow; border: 2px solid orange; }
option { background: #ffc }
p { background: #ddd; }
#P_1 { background: azure; color: blue; text-align: justify }
</style>
<p>
<select>
<option>100
<option>200
<option style="backgrou nd: yellow">300
<option>400
</select>
</p>
<p id="P_1"re blah </p>

<http://www.w3.org/TR/CSS21/indexlist.html>

Thank you, what I need is a little different.

First of all, it is interesting that document.fgcolo r propagates into
paragraphs but not into select elements, any idea why?
It does not do that.

It only looks like it does that. Default background color is transparent.
Second, I want to be able to change the colour of the select
tags as a response to a click on a button, so how do I assign
to all select tags a colour in script (as opposed to in style sheet/tag)?
Change a class selector in an element above them. For example, add a
class "detonate" to body.

<style type="text/css">
..detonated select {
background: chartreuse;
}
</style>

using:

<button onclick="docume nt.body.classNa me='detonated'" >detonate</button>
Garrett
Tia

Sep 27 '08 #5

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

Similar topics

1
2390
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php method=post > <select name= "name">
6
2397
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets say I have values selected for all three pull down menus. When I change the first "top-level" menu I want to reset both the second and third menus to the "default" state.
4
2124
by: joiv | last post by:
I'm making a <select></select> with lots of <option></option>. It contains all possible options. Because of the length of the list, I also have an <input type="text">. This is what I wish to do: onKeyDown I want all options that don't contain (or begin with, it doesn't matter which one) the typed letters to be removed from the <select>. My problem is that I don't know of any code to find words and identify
5
8302
by: Brian Foley | last post by:
Hello, I am used to using the label tag with check boxes and radio buttons in html forms. This allows me to click on the text of the label to activate/deactivate the check box / button, rather than having to click on the (possibly small) box or button. I recently tried to assign a label to a select "drop down list", but found that when I clicked on the label text to bring it into focus, the select box was reset to the first entry. ...
14
23212
by: xxbmichae1 | last post by:
I have a <select> object that i've set up an onchange event that fires in IE fine when I use the cursor up and down in the list, but If I use the cursor up and down in Firefox the event doesn't seem to fire until I've left the field....If i use the mouse all is fine, only when using the cursor keys does it not fire the onchange event in FF. Thanks for any help in advance.
6
12991
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this is not an ASP.NET related question, but I know this group is knowledgeable and quick with responses. Thanks
4
3579
by: luftikus143 | last post by:
Hi there, I have a nasty little problem, as so often, only with IE. Here is an screenshot to better illustrate the problem. http://geodata.grid.unep.ch/screenshot13.png The map is clickable (to enable zoom in and other functions). But in this case, I would like to select a value from the drop-down list, which displays as a "drop-up" list because of not having enough space downwards. Now, when I click to select a year, IE interprets this...
4
39340
by: Man-wai Chang | last post by:
-- iTech Consulting Co., Ltd. Expert of ePOS solutions Website: http://www.itech.com.hk (IE only) Tel: (852)2325 3883 Fax: (852)2325 8288
14
9996
mikek12004
by: mikek12004 | last post by:
In a form I have 5 elements (e.g. pictures) and I wish for the user to be able to set the order of appearance. For this I have for each picture a select box (names select1 to select5) with "please select something" as preselected and the rest options are values from 1 to 5. I want when a user selects a number a.k.a ans <option> that number/<option> to be removed from the rest of the select boxes and when the user selects another number the...
0
7939
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,...
1
8078
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5456
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();...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2442
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
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1285
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.