• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change Disabled Button Label Text and Its Shade Color

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not style a disabled button. You need to set it to readOnly to style it.

Eric
 
Andreanes Yosef Vanderlee
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you said is true.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic