PDA

View Full Version : My Slide Show



tpravioti
10-27-2009, 09:08 AM
i believe you can't make a slideshow without javascript (unfortunately)!!
you can use this function in "<script></script>":

var t=setTimeout('photos[0]',2000);
var current=0;

function photos(img) {
document.getElementById('main_img').src=images[img];
current=img+1;
if(current>4) current=0;
timer=setTimeout('photos(current)',2000);
}

of course you must have your photos in an array...

jscheuer1
10-27-2009, 10:11 AM
tpravioti, that code won't work no matter what you add to it.

tpravioti
10-27-2009, 01:53 PM
tak a look at this..


<html>
<head>
<h3 align="center"><b>Photogallery</b></h3>
</head>

<body>
<center>
<img src="http://www.freeiconsdownload.com/site-images/Large/Delicious-Fruits-452.jpg" id="main_img" width="400" height="370"/>

<table><tr>
<td><img src="http://thumbs.dreamstime.com/thumb_235/1202513581PVn24j.jpg" width="75" height="75" onclick="photos(0);" style="cursor: pointer"/></td>
<td><img src="http://www.medindia.net/healthnetwork/images/uploaded-photos/1_93.jpg" width="75" height="75" onclick="photos(1);" style="cursor: pointer"/></td>
<td><img src="http://www.igourmet.com/images/new_landing/fruits-and-vegetables.jpg" width="75" height="75" onclick="photos(2);" style="cursor: pointer"/></td>
<td><img src="http://lh4.ggpht.com/_gKQKwLZ8XUs/Sbwga37kASI/AAAAAAAAAY8/uEJGqqKB-UY/s800/10-Least-Toxic-Conventionally-Grown-Fruits-and-Vegetables-kiwi-banana.jpg" width="75" height="75" onclick="photos(3);" style="cursor: pointer"/></td>
<td><img src="http://www.public-domain-photos.com/free-stock-photos-4-big/food/fruits-and-vegetables.jpg" width="75" height="75" onclick="photos(4);" style="cursor: pointer"/></td>
</tr></table>

<script>

var images=[];
images[0]="http://thumbs.dreamstime.com/thumb_235/1202513581PVn24j.jpg";
images[1]="http://www.medindia.net/healthnetwork/images/uploaded-photos/1_93.jpg";
images[2]="http://www.igourmet.com/images/new_landing/fruits-and-vegetables.jpg";
images[3]="http://lh4.ggpht.com/_gKQKwLZ8XUs/Sbwga37kASI/AAAAAAAAAY8/uEJGqqKB-UY/s800/10-Least-Toxic-Conventionally-Grown-Fruits-and-Vegetables-kiwi-banana.jpg";
images[4]="http://www.public-domain-photos.com/free-stock-photos-4-big/food/fruits-and-vegetables.jpg";

var t=setTimeout('slideshow[0]',2000);
var current=0;

function slideshow(img) {
document.getElementById('main_img').src=images[img];
document.getElementById('imgcnt').value=(img+1)+' from '+images.length;
current=img+1;
if(current>4) current=0;
timer=setTimeout('slideshow(current)',2000);
}

function photos(img) {
document.getElementById('main_img').src=images[img];
}

</script>

<input type="button" value="Start" onclick="setTimeout('slideshow(current)',2000);">&nbsp;&nbsp;
<input type="text" value"1 from 5" id="imgcnt">&nbsp;&nbsp;
<input type="button" value="Stop" onclick="clearTimeout(timer);">

</center>
</body>
</html>


it was my first gallery with slideshow!!hope it helps!!

jscheuer1
10-27-2009, 05:42 PM
I don't see how this line will work:


var t=setTimeout('slideshow[0]',2000);

That's not (with the square brackets) a function call. I'm sure at least some browsers will not error correct that for you.

I see that line is not used though in your finished script, in fact may be removed. However, in the code where I said that would not work, from your first post in this thread, there is nothing to show how the show starts but that syntax and it clearly will not work. So it was a bit dishonest on your part, but probably an honest mistake.