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?
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>
>.
>