Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

black font color of disabled element 1

Status
Not open for further replies.

kaeserea

Programmer
Feb 26, 2003
164
DE
Hello!

I have IE6 and would like to color the font of a disabled input field black. This is the input field:

<input type="text" name="myField" value"myText" disabled="disabled" style="background-color="#DBDAD7">

The problem with this is that the myText in front of the background color #DBDAD7 looks like a relief so that you can hardly read it. The background color cannot be changed as it is the color of our company's style guide.

The make the font black I've tried the following css statements:

color:#000000
color:black
text-decoration:none (to maybe remove the relief effect)

But nothing helped. The color element is simply ignored if the disabled="disabled" is set.

Does anybody know how to make the font black?

Thanx
Eva

 
If you opt to use a span, you could probably style it to look very much like an input box if you want.

But, BRPS is correct. In this case "readonly" is just what you want.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hello you two!

Thanx a lot for the readonly tip. The font-color is just right now. But: another problem has arisen. I use this also for <select> fields. Those can be changed now. Which should not happen though. Any ideas?

Regards
Eva
 
kaeserea said:
I use this also for <select> fields. Those can be changed now. Which should not happen though.
Why do you have form controls on the page that should not be altered. This could be confusing to the users. You should look into doing whatever you are doing otherwise.
 
Hello Vragabond,

I have my reasons for doing this: we have a complex form which has to have disabled elements for some users (access restriction). And as the form is a complex one generated by a JSP I don't want to have lots of if statement like (if this user then display it this way). And our customers wants the user to see that others before him have altered the select element and that now he cannot do it anymore. That's the reason why.

Regards
Eva
 
Just checked MSDN. For some reason MS thought it was a good idea to supply a readonly property for textboxes, but NOT for select lists. You'll have to try something else. Maybe adding this to the select tag would work:
Code:
   onfocus = "this.blur();"


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi Tracy Dryden,

Thanx for your information and for looking it up. (Where can I find such information?) If MS doesn't do it so the JavaScript is probably the best way to do it.

Eva
 
The Microsoft Developers Network (MSDN) is one of my favorite references, especially for HTML/DHTML/CSS. Here's a link to the DHTML/CSS part:


Just be aware that, since its MS, some of the things shown there are IE-specific and don't work in FF. A good clue is to look at the bottom of the page where it says "Standards Information". If it says there is not standard, then it is most likely IE-only. If it mentions a standard, then FF and others probably have it too.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top