Solved

image timer

Posted on 2008-10-30
4
160 Views
Last Modified: 2013-11-05
I can not get this code to work, what am I doing wrong.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" 
 

dir="ltr">
 

<head>
 

<meta http-equiv="content-type" content="text/html; charset=iso-8859-
 

1" />
 

<title>ConcertAd</title>

<script type="text/javascript">

/*<![CDATA[ */
 

if (curImage == "concert2")

{

document.images[1].src = "concert1.gif";

	curImage = "concert1";

}

else 

}
 

document.images[2].src = "concert2.gif";

curImage="concert2";

}
 

/*]]>*/

</script>
 

</head>
 

<body onload ="var begin=setInterval ('changeImages( )', 5000);">

<p><img src="concert1.gif"  alt=""/></p>

</body>

</html>

Open in new window

0
Comment
Question by:munzie
4 Comments
 
LVL 16

Accepted Solution

by:
Lolly-Ink earned 50 total points
ID: 22847261
Here's a cleaner version of your code with fixes applied:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">

<head>

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

   <title>ConcertAd</title>

   <script type="text/javascript">

      var curImage = "concert1";
 

      function changeImages()

      {

         if (curImage == "concert2")

         {

            document.images[0].src = "concert1.gif";

            curImage = "concert1";

         }

         else 

         {

            document.images[0].src = "concert2.gif";

            curImage="concert2";

         }

      }

   </script>

</head>

<body onload="setInterval('changeImages()', 5000)">

   <p><img src="concert1.gif"/></p>

</body>

</html>

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 22847303
>>what am I doing wrong.
You are "opening" your else with "}":
else
}


 It should be "{"
else
{
0
 
LVL 18

Expert Comment

by:wilq32
ID: 22849650
yes and you forgot to define:

var curImage="concert1";

0
 

Author Comment

by:munzie
ID: 22853452
Thanks, I see what was wrong.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now