faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

Is NN4 supports the diasbled attribute for text field

Apr 5th, 2008 20:03
ha mo, 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
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com