my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Change Disabled Button Label Text and Its Shade Color Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Change Disabled Button Label Text and Its Shade Color" Watch "Change Disabled Button Label Text and Its Shade Color" New topic
Author

Change Disabled Button Label Text and Its Shade Color

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I would like to set the label text color of disabled buttons when the page is loaded. I have a drafted the code but the code does not work.

How to check which buttons are disabled when loading the page and have the label text color on those buttons set?
Andreanes Yosef Vanderlee
Greenhorn

Joined: Mar 30, 2007
Posts: 12
maybe you can try this:

function renderForm(frm){
if(!frm){
frm = document.forms[0];
}
for(var i=0; i<frm.elements.length; i++){
if(frm.elements[i].type == 'button' && frm.elements[i].disabled){
frm.elements[i].className = 'disabledButton';
}
}
}

add <body on load="renderForm()">

or just use css like this:
input isabled{
BORDER-LEFT: #FFFFFF 1px solid;
BORDER-TOP: #FFFFFF 1px solid;
BORDER-RIGHT: #006699 1px solid;
BORDER-BOTTOM: #006699 1px solid;
FONT-SIZE: 1em;
FONT-WEIGHT: bold;
FONT-FAMILY: Arial, Helvetica, sans-serif;
COLOR: #006699;
BACKGROUND-COLOR: #C0C0C0;
}

It works on firefox.. *dunno with other browser..

--
Andre
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Thanks Andreanes, your code works well. The code picks up the style setting when the page is loaded.

Nevertheless, only the text font, background and border colors are correctly set for the disabled button. The color of the label text for the disabled button is not picked up.

Does it mean that there is no way to change the text color on disabled buttons?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can not style a disabled button. You need to set it to readOnly to style it.

Eric
Andreanes Yosef Vanderlee
Greenhorn

Joined: Mar 30, 2007
Posts: 12
Hm... You can't set the text color of disabled button in IE, but it works with firefox.. Correct me please...
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
What you said is true.
 
 
subject: Change Disabled Button Label Text and Its Shade Color