Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 20th, 2004, 10:43 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default getElementByID error

Hi everyone! I am trying to study the getElementByID method. I came up with this simple code...

<html>
<head>
<title>Untitled Document</title>

<!--
<script>
function fnGetId(){
   // Returns the first DIV element in the collection.
   var oVDiv=document.getElementById("oDiv1");
    alert (oVDiv);
}
</SCRIPT>
-->

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" >


<DIV ID="oDiv1">Div #1</DIV>
<DIV ID="oDiv2">Div #2</DIV>
<DIV ID="oDiv3">Div #3</DIV>
<INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">

</body>
</html>


however, it won't work. I don't know what's wrong with it. There error I get says "Object expected." Can somebody help me please?? thanks!

  #2 (permalink)  
Old December 21st, 2004, 01:42 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i found the error..the tags should be placed in between the <script> tags...thanks!



Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio controls and getElementById roccosiffredi BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 0 February 7th, 2008 07:17 PM
Using typeOf with getElementById() atcs2152 Javascript 2 December 16th, 2005 08:19 AM
Using getElementById Frank Huddleston XML 4 November 11th, 2005 01:44 PM
'getElementById()' anshul Javascript How-To 1 September 1st, 2004 03:57 PM
document.getElementById(). PKC XSLT 0 July 21st, 2004 02:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.