...

readonly attribute

Vlaad
05-28-2003, 01:29 AM
Hello people,

I'm having a niggling difficulty using Internet Explorer, where the following code:
x.setAttribute('readonly','true');
does NOT set the readonly attribute to true.

It's working fine in Mozilla, so I can't really see what the problem is (though I encountered something I'm guessing is pretty much the same in the x.className VS x.setAttribute('class','name') function problem.

It's just a simple problem, but it's annoying the crap out of me.

Please help!

Much appreciated!

jkd
05-28-2003, 01:37 AM
Try using the DOM2 HTML extension:

someElement.readOnly = true;

Zvona
05-29-2003, 11:18 AM
Another way that should work:

oElement.setAttribute("readonly","readonly");

This is because attribute readonly can have only value "readonly". However, when dealing with booleans and controlling elements solely thru scripting, it's recommended to use the method jkd mentioned.

brothercake
05-29-2003, 02:54 PM
My experience is that

obj.setAttribute('foo','bar');

often doesn't work in IE, for no reason, whereas

obj.setAttribute('foo','');
obj.foo = 'bar';

is reliable.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum