This is great. It helped me a lot.

I do have one minor suggestion. When handling properties changes for the Select, you should also handle changes to selectedIndex. This is to prevent unproper behaviour after you assign it programmatically.

===

function onPropertyChangeSelect() {
var sChangedPropertyName = event.propertyName.toLowerCase();
if (sChangedPropertyName == "onchange") {
hackOnChange();
}
else if (sChangedPropertyName == "selectedindex") {
nLastSelectedIndex = element.selectedIndex;
}
}

===

Thanks for the code. I'm assuming you are releasing it as public domain?
Posted by Zecc at 2006/10/18 20:29
Thank you for the suggestion, Zecc!

Yes, it's public domian. Feel free to use it. Is your suggestion also public domain? Assuming so, I have merged your code, so other people can benefit from it.
Posted by apptaro at 2006/10/19 13:10
Thank you so much, I have been looking for a solution to this problem for some time.
Much appreciated
Posted by Mr F at 2007/05/21 19:59
Quick note just by adding a few lines the options that are selected='selected' option will also work which is a problem in ie

it is a very quick and dirty addition

function onPropertyChangeOption() {
var sChangedPropertyName = event.propertyName.toLowerCase();
if (sChangedPropertyName == "disabled") {
emulateOption();
}
else if (sChangedPropertyName == "selected") {
emulateOption2();
}
}



function emulateOption2() {
if (element.selected) {
element.style.color = "gray";
} else {
element.style.color = "menutext";
}
}
Posted by Mr F at 2007/05/21 21:20
what about Safari?
Posted by ilia at 2007/05/22 01:55
Safari 3 fixes this problem.

Posted by Mr K at 2007/06/26 04:21
Thanks a lot for these 2 reasons :
1 - You (almost) saved my (customers) life !
2 - I have discover DHTML bevaviors (sweeet...)
Posted by hadrien at 2007/09/25 23:31
Thnx ALOT!!!!!
You saved my day..., not to say a week!

Posted by per at 2007/10/02 02:35
Please I need some help on how I can use sample.htc and sample.css with a php code to let selection disabled in IE.
Thanks in advance
Posted by Alven at 2007/10/05 06:39
A comment to Alven and others. May be just slightly off the topic, but it's something I've seen quite a bit.
I see people who ask how do I use a piece of javascript, or in this case an htc behavior file with PHP. When coding in PHP you need to think with an HTML mindset. If you had a regular HTML file that you were going to impliment this in, how would you do it.

Now back on track, as Apptaro added in the main post.

select, option {
behavior: url(sample.htc);
}

This can be added as CSS code in your HTNL file or as a separate included file.

SO then how do you put this into your PHP scripts. Add it in the same area that you would if you were adding it to a standard HTML file.

IF you view the source of the page generated by your script, you can probably figure it out very easily.
