This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes greying out of text field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "greying out of text field" Watch "greying out of text field" New topic
Author

greying out of text field

AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
Hi,

I want to disable a textfield depending on the value from a select menu.

i use javasrcipt (onchange) on the select, and disable the textfield

document.getElementById('repair').disabled=true;
document.getElementById('repair').styleClass='textDisabledClass';

the textfield has a styleId = 'repair' and i am using html:text (part of struts)

The disable works but styleClass does not change in IE. If works well in Mozilla, i can see two different types of textfields depending on the styleClass.


Any suggestions?

thanks

Anil
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
With IE, you can not style a disabled field. You would have to use the readOnly property to do that.

Eric
AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
Hi Eric,

How do you use readOnly property to style a disabled field?

I tried using readOnly but it still does not change the styleClass of the textfield.

thanks

Anil
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Instead of using disabled property, replace it with readOnly.

Eric
AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
Hi Eric,

I tried it, but still the styleClass does not change. Is it possible to hide the textfield?

thanks

Anil
 
 
subject: greying out of text field
 
Similar Threads
Visual JSF, checkbox and Textfield behavior
Enable/Disable the datepicker
JFileChooser - Do not allow any input in the textfield
Problem with ProGuard 4.4/4.5 and JTextField in Netbeans
Color changes of a button shows in IE but not showing in Mozilla Firefox