Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disabled style

0 views
Skip to first unread message

Martin H

unread,
May 23, 2002, 7:06:18 AM5/23/02
to
Is there anyway to set the disabled style for HTML
controls?

I want the text to stay the same colour when the control
is disabled.

I used the readOnly attribute for the input-text controls,
but this attribute does not seem available for the Select
Controls, or checkboxes etc..

Any ideas?

Jean-Francois Landreau

unread,
Jun 5, 2002, 8:20:35 AM6/5/02
to
Hi,

Hope this sample would help you:

<html>
<head>
<style>
.disabledStyle
{
color:black;
}

input:disabled // doesn't work
{
color:red;
}
</style>
<script>
function disable()
{
myLabel.disabled = true;
myInput.disabled = true;

myLabel.classname = "disabledStyle"; //
Unfortunately that doesn't work either. (only a problem
with font color)
myInput.classname = "disabledStyle";
}

function disable2()
{
myInput.readOnly = true;
myInput.hideFocus = true;
myInput.tabIndex = -1;
// nearly the same thing as disabled
without the problem of font color.
}
</script>
</head>
<body>
<button onclick="disable();">Disable</button> <br>
<button onclick="disable2();">Disable
2</button><br>
<label id="myLabel">MyControl</label><input
id="myInput" value="some text"/>
</body>
</html>

>.
>

0 new messages