.NET Framework Bookmark and Share   
 index > JScript for the .NET Framework > Error changing document.all to document.getElementByID
 

Error changing document.all to document.getElementByID

I am getting errors when I change document.all() to document.getElementByID(). My site is ASP.NET 2.0. Everything works fine (in IE 7) with document.all(), but FF and Chrome and IE8 are all dying when they get to the document.all() call. The exact error I get is "Error: Object doesn't support this property or method".
<script type="text/javascript" language="javascript">
function setCheckedValue(radioObj, newValue) 
{
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) 
	{
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) 
	{
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) 
		{
			radioObj[i].checked = true;
		}
	}
}
var rbl = document.getElementByID('rblRadio');
setCheckedValue(rbl,0);
</script>
rblRadio is a radio button list that is created using a NET repeater control. Could that have something to do with it? The website is using master pages... I can't think of anything else that may be pertinent... I must be missing something here as I have been led to beleve that document.getElementByID is pretty much the basis of much of javascripts functionality. I can't imagine it not being supported...

Thanks for any help in advance!
-Greg
smithygreg
Hi Greg,

I search the error on the net and find some information may help. Please see the following discussion and documentation,

http://www.codingforums.com/showthread.php?t=44364
http://bytes.com/groups/javascript/90931-getelementbyid-errors
http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx

I think the problem here is Javascript is case sensitive and the real function we need to call is getElementById instead of getElementByID.

Hope this resolves your issue. Have a nice day!

Best regards,
Ji Zhou
  • Marked As Answer bysmithygreg Friday, June 12, 2009 3:31 PM
  •  
Ji.Zhou
Hi Greg,

I search the error on the net and find some information may help. Please see the following discussion and documentation,

http://www.codingforums.com/showthread.php?t=44364
http://bytes.com/groups/javascript/90931-getelementbyid-errors
http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx

I think the problem here is Javascript is case sensitive and the real function we need to call is getElementById instead of getElementByID.

Hope this resolves your issue. Have a nice day!

Best regards,
Ji Zhou
  • Marked As Answer bysmithygreg Friday, June 12, 2009 3:31 PM
  •  
Ji.Zhou
Well..I feel like a real ninny... I've been using .all all this time because I had the CASE wrong on getElementyId.
Thank you very much...
smithygreg

You can use google to search for other answers

Custom Search

More Threads

• WScript.Shell, SendKeys, backslash & vista
• jscript settatribute and event model
• I want to know if I can use Javascript in Jscript or Jscript is javascript ,why do i need to use jscript in vs.net environment?
• .Net 1.1 Windows control vs .NET 2.0
• Div Scroll
• Transferring the content
• delete XML node with JavaScript/JScript
• Accessing C# classes from IE (JScript)
• Where the J2EE Application Server Stands in the Scheme of Things
• JScript error Object doesn't support the property or method