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

Why doesn't document.GetElementByID("MyName").submit(); work?

P: 2
Hi;

I've seen lots of discussion & disagreement on this issue, so any good explanation would be appreciated.

Some people seem to think that "document.GetElementByID("MyName").submit(); should and does work. I and others have experienced that it should & doesn't work. I'll give you a little file that I tested with IE 6, FF 3, Opera & Chrome. Only the form button, document.myname.submit(); and document.forms['MyName'].submit(); worked. Take a look & let me know if I've done something wrong, or if there is a good reason that shouldn't work.

Thanks,

Chris

----- Code -----
[HTML]<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link type="text/css" rel="stylesheet" href="MyStyleSheet.css"/>
<title>TestJS</title>
</head>

<script language = JavaScript>
document.write("Hello World")
</script>
<body>

<FORM id="myform" name="myform" ACTION="tst.php">

<INPUT TYPE="SUBMIT" VALUE="Click for a Message Box" onclick="alert ('Button Pressed');">

<div onclick="javascript:alert('Hello!');document.myfor m.submit();"> Click Me! </div>
<div onclick="javascript:alert('Goodby!');document.GetE lementByID('myform').submit();"> <br/><br/><b>No, Me!</b><br/><br/> </div>
<div onclick="javascript:alert('It is sunny today.');document.forms['myform'].submit();"> <br/><br/><b>I say, Me!</b><br/><br/> </div>

</FORM>



</body>
</html>[/HTML]
Oct 28 '08 #1
Share this Question
Share on Google+
2 Replies


P: 55
getElementById....it's spelled wrong....and it should work, it's a method with a return, than means assignment inside of it's own scope....

actually if you google "GetElementByID", you get a list of sites that tell you how to use it properly;)
Oct 28 '08 #2

P: 2
Moving into JavaScript from a case insensitive environment.

Thanks.

getElementById....it's spelled wrong....and it should work, it's a method with a return, than means assignment inside of it's own scope....

actually if you google "GetElementByID", you get a list of sites that tell you how to use it properly;)
Oct 28 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.