|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Fomatting "<input type=text readonly..." fields using CSS
Can anyone tell me how to change the colour of an input field on a form when it is readonly so that the user knows that it is readonly. Would like to be able to accomplish this by simply adding some code to the css file so that I don't have to update the existing jsp's.
Thanks, Simon. |
|
#2
|
|||
|
|||
|
The good news: CSS2.
![]() Code:
input[readonly] {background: buttonface;}
The bad: you got it - not in IE (except IE5+ Mac). How stringent is that restriction? |
|
#3
|
|||
|
|||
|
The project spec is IE5 so I'll give the "input[readonly]" tag a go. I've started to remove all the readonly feilds and replace then with simple text but it will be a greadt help if I can change the colour in the css.
Is the style sheet defined in exactly the same way, i.e. can I simply slot the "input[readonly]" tag into the existing stylesheet? Thanks very much for you help. Simon. |
|
#4
|
|||
|
|||
|
Simon....oops.
Quote:
Yes to your second question. It's a selector. http://www.yourhtmlsource.com/style....html#attribute http://www.xs4all.nl/~ppk/css2tests/intro.html |
|
#5
|
|||
|
|||
|
Thanks for you help. The sites included are very useful. I wonder how long before IE will support?
Simon. |
|
#6
|
|||
|
|||
|
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>untitled</title>
<style type="text/css">
input.readonly {background: buttonface;}
</style>
<script type="text/javascript" language="javascript">
function init_fields()
{
var el, els, e, f = 0, form, forms = document.getElementsByTagName('form');
while (form = forms.item(f++))
{
e = 0; els = form.getElementsByTagName('input');
while (el = els.item(e++))
if (el.readOnly)
el.className = 'readonly';
}
}
onload = init_fields;
</script>
</head>
<body>
<form>
<input id="readonly" type="text" name="readonly" value="readonly" readonly="read-only">
<input id="readwrite" type="text" name="readwrite" value="read/write">
</form>
</body>
</html>
|
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Fomatting "<input type=text readonly..." fields using CSS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|