By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

checkbox checked property "undefined" in IE

P: n/a
Hello,

The following code:

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

<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

Oct 6 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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).check ed);
}
//-->
</script>
</head>
<body>
<input name="strMenuQA" id="strMenuQA" type="checkbox" value="1"
onclick="checkChildMenuItems(this.id);" checked="checked">
</body>
</html>

Oct 6 '05 #2

P: n/a

fr***********@gmail.com wrote:

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

<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);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 6 '05 #3

P: n/a
Martin Honnen schreef:
fr***********@gmail.com wrote:

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

<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);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/

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

Oct 6 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.