View Full Version : Changing background color of disabled fields in IE6

10-17-2007, 04:48 PM
This is the page in question: http://www.supernovapatents.com/searchform.php

I'm having a devil of a time trying to make it so that my input fields gray out in IE6. Everything works fine in Firefox. I've tried using javascript to dynamically insert a class="disabled" in the input elements, then tried to style it in CSS to no avail.

My stylesheet can be found here:


The stylesheet is a convoluted mess, I am sorry. The search form section begins on line 173. I've experimented with a number of things to try to get it to work.The last thing I tried to do was this:

background-color: gray;

Basically, I want to make it so that when a user clicks "paypal" all the billing fields below gray out, and when a user clicks "same address" all the address fields below gray out. The relevant javascript is in the header of searchform.php.

For some reason the "same address" checkbox grays out appropriately in ie6, but none of the other fields do. I have no idea why this is. Any help would definitely be appreciated.

10-17-2007, 05:03 PM
IE actually interprets "setAttribute" to work on the javascript object iteself, and that makes things unpredictable. That's why you can't use things like object.class or object.for in IE (because it's a collision with the javascript reserved word).

Instead use:

el.className = 'disabled';

which although is technically IE's way of getting around its own reserved word collision it also works in mozilla as well. If you'd rather conditionally only use "className" for IE, you could use this as well:

el.setAttribute((document.all ? ‘className’ : ‘class’), 'disabled');

10-17-2007, 05:07 PM
Bah. No way to delete a double-post FTL.

10-17-2007, 06:05 PM
That worked perfectly. Thank you so much. :thumbsup: