rotating images with link

this is what i have so far. my images work fine but the link doesn't get change. could you help please.
if i take out document["ChangingLink"].href = Links[PicCurrentNum]; then my images loop through fine. but i also want my image to have link on them. the error i'm getting is document.ChangingLink is null or not an object. thank you
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
	var timeDelay = 5; 
	var Pix = new Array
	("images/1.jpg" 
	,"images/2.jpg" 
	,"images/3.jpg" 
	,"images/4.jpg" 
	);
	var Links = new Array
	("http://www.yahoo.com",
	 "http://www.google.com",
	 "http://www.etrade.com",
	 "http://www.microsoft.com"
	);
	var howMany = Pix.length;
	timeDelay *= 1000;
	var PicCurrentNum = 0;
	var PicCurrent = new Image();
	PicCurrent.src = Pix[PicCurrentNum];
	function startPix() {
	setInterval("slideshow()", timeDelay);
	}
	function slideshow() {
	PicCurrentNum++;
	if (PicCurrentNum == howMany) {
	PicCurrentNum = 0;
	LinkCurrentNum = 0;
	}
	PicCurrent.src = Pix[PicCurrentNum];
	document["ChangingLink"].href = Links[PicCurrentNum];
	document["ChangingPix"].src = PicCurrent.src;
	}
</script>
</head>
 
<body OnLoad="startPix()">
<a name="ChangingLink" id="ChangingLink" href="http://www.yahoo.com"><img name="ChangingPix" src="images/1.jpg" border="0"></a>
 
</body>
</html>

Open in new window

StewSupportAsked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
try:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
      var timeDelay = 5; 
      var Pix = new Array
      ("images/1.jpg" 
      ,"images/2.jpg" 
      ,"images/3.jpg" 
      ,"images/4.jpg" 
      );
	 
      var Links = new Array
      ("http://www.yahoo.com",
       "http://www.google.com",
       "http://www.etrade.com",
       "http://www.microsoft.com"
      );
	 
      var howMany = Pix.length;
      timeDelay *= 1000;
      var PicCurrentNum = 0;
      var PicCurrent = new Image();
      PicCurrent.src = Pix[PicCurrentNum];
	 
      function startPix() {
      setInterval("slideshow()", timeDelay);
      }
	 
      function slideshow() {
      	PicCurrentNum++;
      	if (PicCurrentNum == howMany) {
      		PicCurrentNum = 0;
      		LinkCurrentNum = 0;
      	}
      	PicCurrent.src = Pix[PicCurrentNum]; 
      	document.getElementById("ChangingLink").href = Links[PicCurrentNum];
      	document.getElementById("ChangingPix").src = PicCurrent.src;
      }
</script>
</head>
 
<body OnLoad="startPix()">
<a name="ChangingLink" id="ChangingLink" href="http://www.yahoo.com"><img name="ChangingPix" id="ChangingPix" src="images/1.jpg" border="0"></a>
 
</body>
</html>

Open in new window

0
 
hieloCommented:
try:
document.images["ChangingLink"].href = Links[PicCurrentNum];
      document.images["ChangingPix"].src = PicCurrent.src;
0
 
StewSupportAuthor Commented:
thank you. just do documnet.getElementByID("").href
sob. don't know why it didn't work with just document.
0
 
hieloCommented:
you are welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.