[Javascript] IE work-a-round question (re: checkboxes)

Peter Brunone peter at brunone.com
Fri Apr 11 16:24:28 CDT 2008


Hi Tedd,

    Are you sure you're not mistaken?  I have never heard that IE wouldn't respect document.getElementById, and in fact when I tried just now to check a checkbox via Javascript, it worked for me.  My code looked exactly like this:

document.getElementById("ShouldDisplayAttachments").checked=true;

    And please...  I'm no Microsoft flunkie, but acting like they're singlehandedly holding back the web?  That's just a teeny bit silly.

Cheers,

Peter

----------------------------------------

From: tedd tedd at sperling.com 

Hi gang:

I wrote the following application and it works fine on most browsers 
except for IE's.

http://webbytedd.com/quarters

It seems that IE js doesn't understand the following statement:

document.getElementById(id).checked = true;

Granted all that line does is to set a checkbox variable (id) to 
'on'. Surely, some $M code can do that, right?

After reading a bunch, it seems that M$ has a better way to do things 
(big surprise there, huh?) and thus does not use the 
document.getElementById(id) thing that everyone else in the world 
uses. Instead, they use something "better" and it's not documented 
well, as is typical.

Unfortunately, I have not been able to find a work-a-round.

So, what I need is:

if (document.getElementById)
{
document.getElementById(id).checked = true;
}
else
{
<<<<< inset solution here. >>>>>>
}

All the code has to do is to set a simple checkbox to 'on' in IE.

Anyone have any ideas?

Cheers,

tedd

PS: I've posted this question on the php list as well.

PSS: You have to wonder how much more technically advanced we would 
be if we weren't always held back by the "what's in it for me" 
shortsightedness of M$.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20080411/4c1cdba7/attachment.htm>


More information about the Javascript mailing list