View Single Post
Old 05-18-2008, 07:54 PM   #1 (permalink)
sarmenhb
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 287
Thanks: 42
sarmenhb is on a distinguished road
Default newb in javascript need help

hi, im doing this from a book and its not working what am i doing wrong?

here is my code
when i click on the first or second button i get this error

getvalue() is not defined

or

getValueTagName is not defined
onclick(click clientX=0, clientY=0)


Code:
<html>
<head>
<script type="text/javascript">

function getValueID() {

var byid = document.getElementById("listitems");
alert(byid[1]); //displays undefined
alert(byid.innerHTML); //displays all of ul's li items
alert(byid.parentNode); // parent node
alert(byid.childNotes[2];// shows second li item
alert(byid.firstChild); // shows first li
alert(byid.lastChild);// shows last li
alert(byid.nextSibling);
alert(byid.lastSibling);

}

function getValueTagName() {

var bytag = document.getElementByTagName("li");
alert(bytag[1]);


}

function getattrib() {

var link = document.getElementbyId("listitems");
alert(link.getAttribute("link");


}

</script>
</head>
<body>
<a href="http://google.com" id="link">google</a><br>

<ul id="listitems">
<li>first</li>
<li>second</li>
<li>third</li>
</ul>

<input type="submit" value="getValueID" onclick="getValueID()"/><br>
<input type="submit" value="getValueTagName" onclick="getValueTagName()"/><br>
<input type="submit" value="getAttribute" onclick="getattrib()"/><br>



</body>
</html>
__________________
IAD Design & Studio will provide all your needs regarding web design,logo design, and more...
visit http://www.iaddesignandstudio.com for more information.
Send a message via AIM to sarmenhb Send a message via MSN to sarmenhb Send a message via Yahoo to sarmenhb Send a message via Skype™ to sarmenhb
sarmenhb is offline  
Reply With Quote