Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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
 
Old June 26th, 2005, 05:35 AM
Authorized User
 
Join Date: Aug 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Want to run more than one Slideshow on the page

Friend asked me to help him with a page which holds more than one slideshow ( don't know why he wants to do it like that).
Firstly we created single slideshow which works nicely. Than we added second one be simple copy and paste "div & img" tags and change their id's. Our problem? When you do mouseover second "div" script is running slide show on the first one "pics1" instead of second "pics2". We can't figured out where is our mistake? Why is not running properly?
Code:
<html>
<head>
<title>Untitled</title>

<script language="javascript">
var currentImage = 1;
var timer;

image1 = new Image();
image1.src = "image1.jpg";

image2 = new Image();
image2.src = "image2.jpg";

image3 = new Image();
image3.src = "image3.jpg";

image4 = new Image();
image4.src = "image4.jpg";

image5 = new Image();
image5.src = "image5.jpg";


function ChangeImage(pics) 
{
    if (currentImage > 5) 
        {
            currentImage = 1;
        }
        document.images(pics).src=eval("image"+currentImage+".src")
        currentImage++;

        timer = setTimeout("ChangeImage()", 1000);


}

function Stop(pics)
{
    currentImage = 1;
    document.images(pics).src=eval("image"+currentImage+".src")
    clearTimeout(timer);
}
</script>

</head>
<body>

<div id="div1" style="position: absolute; top: 100px; left: 900px; width: 30px; height: 10px; border: solid;" 
onMouseOver="ChangeImage('pics1')" onMouseOut="Stop('pics1')">
</div>
<img src="image1.jpg" name="pics1" id="pics1">
<br>
<br>

<div id="div2" style="position: absolute; top: 500px; left: 900px; width: 30px; height: 10px; border: solid;" 
onMouseOver="ChangeImage('pics2')" onMouseOut="Stop('pics2')">
</div>
<img src="image1.jpg" name="pics2" id="pics2">

</body>
</html>
Any idea where is problem with this script.
Thanks for help and advice

P.T.
__________________
P.T.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax Slideshow Kerensky18 Ajax 3 June 1st, 2008 12:29 PM
how to run a page from Apache tomcat hafizmuhammadmushtaq Apache Tomcat 1 April 11th, 2008 03:38 AM
how to link slideshow images on js gilgalbiblewheel Javascript How-To 1 January 25th, 2007 07:16 AM
SlideShow k_kosaraju .NET Framework 2.0 1 March 5th, 2006 07:17 PM
error in an xml javascript based slideshow Looney Classic ASP Basics 4 June 6th, 2005 01:16 AM





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