Someone told me that you do, actually, have the ability to style "disabled" form elements using javascript and CSS in IE (crossbrowser would be preferrable). Anyone know how to accomplish this? Help is much appreciated.
dep
jscheuer1
03-16-2006, 07:43 PM
You don't even need javascript for that:
<input type="text" style="font-size:.75em;border:2px dotted pink;" disabled>
But, if you want to use javascript to change the style of a disabled form element, you can do it in all of the usual ways you can for an enabled form element, one example:
<input id="test" type="text" style="font-size:.75em;border:2px dotted pink;" disabled>
<input type="button" onclick="document.getElementById('test').style.borderColor='black'">
mrhoo
03-16-2006, 08:35 PM
I bet you were looking for a pseudo- class; like an a:active style declaration.
I looked too. If you want your buttons and other items to LOOK disabled when they are disabled you have to do it yourself.
Something like:
function bigDis(boo, hoo){
var A=collect(hoo);
if(!boo || boo==='false')boo= false;
for(var i=0; i< A.length; i++){
var who= A[i];
disStyle(who,boo);
if(boo) who.disabled=true;
else who.disabled=false;
}
}
function disStyle(who,boo){
var c=(boo)? 'gray' : '';
if(boo) mrs(who,'textDecoration:line-through;cursor:wait;color:'+c);
else mrs(who,'cursor:pointer;textDecoration:none;color:'+c);
}
You can pass bigDis() one or an array of elements,
collect() makes sure they all exist before looping them.
mrs() is a shortcut to element.style[name]=value for multiple style changes.
jscheuer1
03-16-2006, 11:59 PM
mrs() is a shortcut to element.style[name]=value for multiple style changes.
Impressive mrhoo but, I'd like to meet mrs(who,boo), the function that is, not to mention collect().