How to make a textbox readonly? using JS

aladdin357
aladdin357 used Ask the Experts™
on
Hello,

Got a quick question, hope somebody can help me with this. I have a page, when user clicks on one of the buttons, it pops up another page. Based on some criteria in that pop up page, it will make one of the text boxes in the parent page, readonly. I am not able to get that. I tried the following code, I am not getting an error, but it is not making my text box readonly...

opener.document.forms[0].txtDescription.Readonly = true;

also I tried this one:

opener.document.forms[0].txtDescription.onfocus= "this.blur;";

I appreciate if anybody can help me with this...

Thanks....

TA
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Finance Systems Developer
Commented:

opener.document.forms[0].txtDescription.readOnly = true;
Note the spelling of readOnly

Author

Commented:
Thank U very much..
Top Expert 2005

Commented:
The above is a great solution but it may not work with earlier versions of Netscape. What you can do is on the control itself, do this:

<inpu type=text name=txtDescription onFocus="javascript:blur()">

Fritz the Blank

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial