Thursday, November 15, 2007

IE7 .NET and disabled radio buttons

Trying to have disabled radio buttons on a black background was hairy in .NET

Because .NET puts them in spans and sets disabled="disabled" they were getting a white drop shadow. Of course when you have radio buttons on a white background you don't notice this, but on a black background it was ugly.

Here is the javascript we used to strip the spans of the flag (and since the radio input itself was disabled, it still worked fine). Thanks to Josh for coming up with the javascript.

var els = document.getElementsByTagName("span");
for(var i = 0; i<els.length;i++)
{
els[i].removeAttribute('disabled');
}

4 Comments:

Blogger weaselofdoom said...

It's important to note that this applies to all labels on all disabled form elements, not just radio buttons. Any label wrapped in a span with an attribute disabled will exhibit this behavior.

It's equally important to note that disabled is not a valid attribute of span.

11:01 AM  
Anonymous Josh Pope said...

Ahhh the wonders of javascript ;)

Glad to see this was useful to you! Hopefully someone out there will run into the same issue and find the solution here.

-josh

8:50 PM  
Anonymous Anonymous said...

What is captcha code?, pls provide me captcha code codes or plugin, Thanks in advance.

rH3uYcBX

12:21 AM  
Anonymous Anonymous said...

Wow! what an idea ! What a concept ! Beautiful .. Amazing …

rH3uYcBX

2:38 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home