View Full Version : IE onclick error with checkbox

06-12-2008, 05:37 PM
I'm having a problem in IE with adding onClick functionality to a checkbox. In Firefox everything works fine, no errors in Firebug. In IE, i get the error message "Invalid Property Value".

Any ideas what the problem is in the following code? All other Javascript running on the page is working ok in both IE and Firefox, so it's only the onclick functions below causing the problem.

event handler code..

function AttachEvent(obj,evt,fnc,useCapture){
if (!useCapture) useCapture=false;
if (obj.addEventListener){
return true;
} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
if (!obj.myEvents) obj.myEvents={};
if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
var evts = obj.myEvents[evt];
function MyFireEvent(obj,evt){
if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
var evts = obj.myEvents[evt];
for (var i=0,len=evts.length;i<len;i++) evts[i]();

and my functions for adding onclick functionality to the checkbox...

function addOnClick () {

var el = document.getElementById("journeyType");
el.onclick = function(){
return disableDateField(el);

function disableDateField (box) {

var date_field = document.getElementById("return_date");
//check if checkbox is checked or not
if (box.checked == true) {
date_field.style.backgroundColor = "grey";
date_field.disabled = true;

else {
date_field.style.backgroundColor = "white";
date_field.disabled = false;


06-13-2008, 01:49 AM
Can we get a link to an example of the site where you're having the problems?

06-13-2008, 10:14 AM
yep sorry i should have posted a link to start with, please excuse the messiness of the site (early stages!) - http://www.maguiresonline.co.uk/development/Touch%20of%20Class/index2.php

06-13-2008, 05:16 PM
Now I see what you're saying, I don't know how you could fix it though. I'm sure someone here can, Good Luck!