[Javascript] readonly in IE7
John Pillion
john at conv-dg.com
Sat Sep 1 15:41:09 CDT 2007
k, I have another question. I'm trying to mark a text box as readonly
(from a 'yes/no' radio pair, where disabledValue is the value from the
radio button - this part works fine). Below is the portion of code,
which will not work in IE7 (possibly all versions of IE?).
var txtBox = document.forms["bldForm"].elements["bldName"];
if (disabledValue.toLowerCase() == "y"){
txtBox.setAttribute('readonly','readonly');
}else{
txtBox.removeAttribute('readonly');
}
I saw elsewhere that the following sometimes is more reliable for IE to
do the following:
txtBox.setAttribute('readonly','');
txtBox.readonly = 'readonly';
this does not work either though, nor does
txtBox.readonly = 'readonly';
More information about the Javascript
mailing list