Entry
Is NN4 supports the diasbled attribute for text field
Dec 1st, 2001 16:29
Dave Clark, sridhar babu,
Sridhar,
No, NS4 does not support the disabled or readonly attributes for FORM
elements. You can, however, commandeer the onFocus event, for these
elements, to perform a similar action. For NS4, the following code
could be executed from the document's onLoad event to do this:
<script language="JavaScript">
<!-- // Begins
function createNewProperties() {
var f, x, i
if (!document.layers) return;
for (f in document.forms) {
x = document.forms[f].elements;
for (i in x) {
if (x[i].onfocus) {
x[i].disabled = false;
x[i].readonly = false;
x[i].onfocus = function () { if(this.disabled||this.readonly)
this.blur(); }
}
}
}
return;
}
// Ends -->
</script>
After execution of that code, you can reference these new properties
just as you would in an IE browser. For example:
document.formName.fieldName.disabled = true; // or false
document.formName.fieldName.readonly = false; // or true
OK? ;-)
Take care,
Dave Clark