By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,445 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,445 IT Pros & Developers. It's quick & easy.

Forecolor of disabled controls

P: n/a

How could I use the color black rather the default grey?

--
iTech Consulting Co., Ltd.
Specialized in providing ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852) 2325 3883 Fax: (852)2325 8288
Feb 16 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 2007-02-16, Man-wai Chang <to***********@gmail.comwrote:
>
How could I use the color black rather the default grey?
You can't control things like that (except possibly in CSS 3, which some
browsers support bits of).

An option is to write your own controls out of images etc. and
Javascript. Or better just get used to the default grey :)
Feb 16 '07 #2

P: n/a
Scripsit Ben C:
On 2007-02-16, Man-wai Chang <to***********@gmail.comwrote:
>>
How could I use the color black rather the default grey?

You can't control things like that (except possibly in CSS 3, which
some browsers support bits of).
That seems to be the case. Explicitly setting the color works for a normal
text input field but not for a disabled text input field. I first thought it
might relate to degree opacity, in which case CSS 3 might indeed have
something to offer, but setting the color, say, to red does not turn it to
pale red. Instead, the browser uses its own shade of grey, as if the style
sheet were not there.
An option is to write your own controls out of images etc. and
Javascript. Or better just get used to the default grey :)
Or best just get rid of disabled controls. What's the point anyway? Why
would you show the user something that looks somewhat like a form field but
does not get submitted along with a form (and cannot be modified).

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 16 '07 #3

P: n/a
Scripsit Jukka K. Korpela:
>>How could I use the color black rather the default grey?

You can't control things like that (except possibly in CSS 3, which
some browsers support bits of).

That seems to be the case. Explicitly setting the color works for a
normal text input field but not for a disabled text input field.
Correction: That's true for IE up to and including IE 7, but Firefox seems
to have no restrictions in this respect. I don't know why you would use a
different color for a disabled field, but if you do, you might consider
using the CSS 3 property opacity as well, to give a visual message of the
disabled state. E.g.,

<input type="text" name="foo" value="bar" disabled
style="color: red; background: white; opacity: 0.5">

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 16 '07 #4

P: n/a
"Jukka K. Korpela" <jk******@cs.tut.fiwrites:
Or best just get rid of disabled controls. What's the point anyway?
Why would you show the user something that looks somewhat like a form
field but does not get submitted along with a form (and cannot be
modified).
I agree that writing the disabling into the HTML is pointless, but not
that being able to disable a control necessarily is.

....
<input type='checkbox' name='q4' value='other'Other (please state)
<input name='q4other' size='40'>
....

It might be a reasonable optional enhancement to this form to use
Javascript to initially set the 'other' <inputto be disabled (which
obviously can't be set as an initial state in the HTML), and then
enable and disable this as the relevant checkbox is used. Similarly
for complex data-collection requirements (e.g. checkbox F is only
available if two or more of checkboxes A, B and C are selected) where
it might help the user's mental model of the data. All optional and
backed up by the same logic server-side, naturally.

Whether this is more or less usable than modifying q4other's display
style between inline and none I'm not sure - I'd have to try both out.

--
Chris
Feb 16 '07 #5

P: n/a
Scripsit Chris Morris:
<input type='checkbox' name='q4' value='other'Other (please state)
<input name='q4other' size='40'>
...

It might be a reasonable optional enhancement to this form to use
Javascript to initially set the 'other' <inputto be disabled (which
obviously can't be set as an initial state in the HTML), and then
enable and disable this as the relevant checkbox is used.
It's better to do that by setting visibility to hidden in JavaScript
initially.
Whether this is more or less usable than modifying q4other's display
style between inline and none I'm not sure - I'd have to try both out.
Setting display to none avoids the rendering issues with disabled controls
and causes less confusion, since the user won't see the text input field
until it is needed and will automatically see it as a normal field when
needed.

But setting visibility to hidden avoids the redraw problem. If you change an
element's display property, the page will generally need to be reformatted
(redrawn) as a whole, whereas toggling visibility affects the particular
element only, since space has been allocated for it anyway.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 17 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.