Click to See Complete Forum and Search --> : How to toggle READONLY attribute for TEXTAREA's?


SAFX
05-07-2003, 11:00 AM
I need to write a function that allows me to set READONLY to true or false on a TEXTAREA, but I can't seem to figure out how to do it. It needs to work in IE 5.5 and up, that's all.

PS: Is it possible to change the "class" attribute of a TEXTAREA, so that you can change colors dynamically?

Thanks,

SAF

Jona
05-07-2003, 11:20 AM
Yes, it's possible.

document.myFormName.myTextareaName.readOnly();

If the above doesn't work, try:

document.myFormName.myTextareaName.readonly=true;

Or if that still doesn't work, try capitalizing "Only" in the example above.

To change the class of the textarea:

document.myFormName.myTextareaName.class="className";

SAFX
05-07-2003, 11:35 AM
Thanks!

I was able to get the readOnly = true; to work fine, but attempting to change the class does not work. I get an error indicating "Object expected".

Any ideas?

Thanks again!

SAF

Jona
05-07-2003, 11:46 AM
I think I had my property wrong, then. Try: document.myForm.myTextarea.className="class_name";

SAFX
05-07-2003, 01:36 PM
Thank you very much! That worked great!

Thanks again,

SAF

Jona
05-07-2003, 02:13 PM
No problem. :)