Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Works On Mozilla but not on IE :(

Status
Not open for further replies.

alshebli

Programmer
Feb 22, 2005
10
US
Hi!

I'm using Javascript to make a form's input read only. I basically open a child window, and then the child window provides it value them makes it readonly. I passes on its value correct, however i can't seem to get the input greyish/readonly.

This is the command I use:

//works on IE! :)
window.opener.document.forms[0].elements['lastname'].value = last;
//doesn't work on IE! :(
window.opener.document.forms[0].elements['lastname'].readOnly = true;

It works beautifully on mozilla, however i can't seem to get it to work on IE. Any suggestions??
 
try
Code:
window.opener.document.forms[0].elements['lastname'].disabled = true;

"It is the mark of an educated mind to be able to entertain a thought without accepting it." - Aristotle
 
Great! it works! It doesn't allow the cursor in the input field, which is what i want. However, it doesn't shade it grey like the other browsers do. It looks exactly the same, only it doesn't allow the cursor on it.

I can see this as being annoying to any user using the system. Having the field shaded grey is a clear indicator that you cannot write on it. This doesn't shade it grey. Is there perhaps another way we can shade the field? :p

I seem to have repeated myself. I hope its not confusing. I appreciate any help. :)
 
for IE you I suppose you could use
Code:
window.opener.document.forms[0].elements['lastname'].onfocus = function () {this.blur()};

"It is the mark of an educated mind to be able to entertain a thought without accepting it." - Aristotle
 
That didn't work. :/ I hate IE. Any other sugguestions?

I thought I'd cheat and actually try to change the background color of the input field, but couldn't figure that out either!
 
I thought for sure I tested this earlier without success, but it seems like its working now:
Code:
window.opener.document.forms[0].elements['lastname'].setAttribute("readOnly","true");
hope that does it for you.

"It is the mark of an educated mind to be able to entertain a thought without accepting it." - Aristotle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top