JavaScript Duh Moment of the Day – 8/1/2007
August 1, 2007
When, oh when, will I remember that other form fields don’t enforce the readOnly attribute like text fields do in JavaScript? I’ve done this before with a list field. I’ve done it before with checkboxes. I think I’ve even fallen victim with radio buttons. And yet, everytime I want to dynamically lock down a field, I forge straight down that path:
document.FormName.DropDownList1.readOnly = true;
Grr. As soon as I pull up the form and see the editable fields, I know exactly what the issue is. Nonetheless, each time I do it, my frustration with this particular forgetfulness compounds. By golly, one day I will get this right the first time!
P.S. In case you are wondering, you can disable the field (at least for IE 6, IE 7 and FireFox 2.0.0.6):
document.FormName.DropDownList1.disabled=true;
Entry Filed under: JavaScript, Web Development. .






Trackback this post | Subscribe to the comments via RSS Feed