var e = document.getElementById(this.htmlFor);
switch(e.type){
case "radio": e.checked|=1;break;
case "checkbox": e.checked=!e.checked;break;
case "text": case "password": case "textarea": e.focus(); break;
}
This adds the onclick event to the LABEL itself, which seems to work very well in IE.
Nice trick, seems to work very well in IE7.
Many thanks! My need for an IE fix is very specific so I just use addEvent in-page, but this helped me confirm it wasn't my HTML or some other specific conflict, just another IE wonkyism.
hi,
You have done a good job. I am facing this problem and I got solution by this. So I am thankful to you. So keep doing such work.
Excellent solution, thanks a lot!
I liked it... But it needs a little modification to fire onclick events of a checkbox, select, or text input. Here is my patched version of this script snipt that need to be modified:
switch (e.type) {
case "radio": e.click(); break;
case "checkbox": e.click(); break;
case "text": case "password": case "textarea": e.focus(); break;
}
Best Regards
The Prototype solution :
Event.observe(window, 'load', function() {
if (Prototype.Browser.IE) {
var imgLabels = $$("label img");
imgLabels.each(function(eachImgLabel) {
Event.observe(eachImgLabel, "click", function() {
var radiolabel = eachImgLabel.ancestors()[0].readAttribute('for');
$(radiolabel).click();
});
});
}
});
http://www.www.avmdanse.com/archives/javascript/using_images_as/
AWESOME Code! Thank you