checkbox checked property "undefined" in IE

F

frank.cleuren

Hello,

The following code:

function checkChildMenuItems(strNameModule)
{
alert(document.getElementById(strNameModule).checked);
}

<input name="strMenuQA" id="strMenuQA" type="checkbox" value="1"
onclick="checkChildMenuItems(this.id);" checked="checked">

shows "true" or "false" in Firefox, when I respectively check or
uncheck the checkbox. IE however comes up with "undefined". Is this
code so exotic, that IE has problems with it??

Thanks in advance!

Frank
 
B

bjc

Hi Frank - Just checked your code. My IE displays true / false. Here's
the page & code I used:

<html>
<head>
<meta name=vs_defaultClientScript content="JavaScript">
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<script language=javascript>
<!--
function checkChildMenuItems(strNameModule)
{
alert(document.getElementById(strNameModule).checked);
}
//-->
</script>
</head>
<body>
<input name="strMenuQA" id="strMenuQA" type="checkbox" value="1"
onclick="checkChildMenuItems(this.id);" checked="checked">
</body>
</html>
 
M

Martin Honnen

function checkChildMenuItems(strNameModule)
{
alert(document.getElementById(strNameModule).checked);
}

<input name="strMenuQA" id="strMenuQA" type="checkbox" value="1"
onclick="checkChildMenuItems(this.id);" checked="checked">

Why do you need to pass this.id at all, why can't you simply pass this
and do
function checkChildMenuItems (element) {
alert(element.checked);
}
 
F

Frank

Martin Honnen schreef:
Why do you need to pass this.id at all, why can't you simply pass this
and do
function checkChildMenuItems (element) {
alert(element.checked);
}


Thanks a lot for the quick reply Martin. I adapted my code, and it
works now!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top