Click to See Complete Forum and Search --> : image slideshow problems


stunter
12-21-2005, 07:03 AM
My slideshow works how i want it to but I cannot figure out how to swap my play button. "play_button.gif" name"slidebutton". I want it to change to stop_button.gif. the same way it would have changed from "start" to "stop" or "stop" to "start" if i used:

<input type=button name="slidebutton" onClick="ap(this.value);" value="Start" title="AutoPlay">

instead of trying to use an image.

Please help!

<head>

<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0

var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}


function MM_preloadImages() { //v3.0

var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}


function MM_swapImage() { //v3.0

var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}


var rotate_delay = 3000; // delay in milliseconds (5000 = 5 secs)
current = 0;
function next() {
if (document.slideform.slide[current+1]) {
document.images.show.src = document.slideform.slide[current+1].value;
document.slideform.slide.selectedIndex = ++current;
}
else first();
}
function previous() {
if (current-1 >= 0) {
document.images.show.src = document.slideform.slide[current-1].value;
document.slideform.slide.selectedIndex = --current;
}
else last();
}
function first() {
current = 0;
document.images.show.src = document.slideform.slide[0].value;
document.slideform.slide.selectedIndex = 0;
}
function last() {
current = document.slideform.slide.length-1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
}
function ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
rotate();
}
function change() {
current = document.slideform.slide.selectedIndex;
document.images.show.src = document.slideform.slide[current].value;
}
function rotate() {
if (document.slideform.slidebutton.value == "Stop") {
current = (current == document.slideform.slide.length-1) ? 0 : current+1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
window.setTimeout("rotate()", rotate_delay);
}
}

//-->
</script>

</head>

<body>


<img src="images/dog_header.gif" style="position:absolute;left:250;">


<div id="mainClm" style="position:absolute;top:125;left:200;">


<center>
<form name=slideform>

<img src="images/begin_button.gif" onClick="first();" title="Beginning">
<img src="images/back_button.gif" onClick="previous();" title="Previous">
<a onClick="MM_swapImage('slidebutton','','images/stop_button.gif',1);">
<img src="images/play_button.gif" name="slidebutton" border=0 onClick="ap(this.value);" value="Start" title="AutoPlay"></a>
<img src="images/next_button.gif" onClick="next();" title="Next">
<img src="images/last_button.gif" onClick="last();" title="End">
<br>

<img src="images/a01010004_08_18_05.jpg" name="show">
<br>

<div id="selectBox" style="width:90;">
<select name="slide" onChange="change();">
<option value="images/a01010004_08_18_05.jpg" selected>Image 1
<option value="images/a01010001_08_18_05.jpg">Image 2
<option value="images/a01010005_08_18_05.jpg">Image 3
<option value="images/a01010006_08_18_05.jpg">Image 4
<option value="images/a01010007_08_18_05.jpg">Image 5
<option value="images/a01010008_08_18_05.jpg">Image 6
<option value="images/a01010009_08_18_05.jpg">Image 7
<option value="images/a01010010_08_18_05.jpg">Image 8
<option value="images/a01010011_08_18_05.jpg">Image 9
<option value="images/a01010012_08_18_05.jpg">Image 10
<option value="images/a01010013_08_18_05.jpg">Image 11
<option value="images/a01010014_08_18_05.jpg">Image 12
<option value="images/a01010015_08_18_05.jpg">Image 13
<option value="images/a01010016_08_18_05.jpg">Image 14
<option value="images/a01010017_08_18_05.jpg">Image 15
<option value="images/a01010019_08_18_05.jpg">Image 16
<option value="images/a01010020_08_18_05.jpg">Image 17
<option value="images/a01010021_08_18_05.jpg">Image 18
<option value="images/a01010022_08_18_05.jpg">Image 19
<option value="images/a01010023_08_18_05.jpg">Image 20
<option value="images/a01010024_08_18_05.jpg">Image 21
<option value="images/a01010025_08_18_05.jpg">Image 22
<option value="images/a01010026_08_18_05.jpg">Image 23
<option value="images/a01010027_08_18_05.jpg">Image 24
<option value="images/a01010028_08_18_05.jpg">Image 25
<option value="images/a01010029_08_18_05.jpg">Image 26
<option value="images/a01010030_08_18_05.jpg">Image 27
<option value="images/a01010032_08_18_05.jpg">Image 28
<option value="images/a01010035_08_18_05.jpg">Image 29
<option value="images/a01010036_08_18_05.jpg">Image 30
<option value="images/a01010037_08_18_05.jpg">Image 31
<option value="images/a01010038_08_18_05.jpg">Image 32
<option value="images/a01010039_08_18_05.jpg">Image 33
<option value="images/a01010040_08_18_05.jpg">Image 34
<option value="images/a01010041_08_18_05.jpg">Image 35
<option value="images/a01010042_08_18_05.jpg">Image 36
<option value="images/a01010044_08_18_05.jpg">Image 37
<option value="images/a01010045_08_18_05.jpg">Image 38
<option value="images/a01010046_08_18_05.jpg">Image 39
<option value="images/a01010047_08_18_05.jpg">Image 40
<option value="images/a01010048_08_18_05.jpg">Image 41
<option value="images/a01010049_08_18_05.jpg">Image 42
</select>
<div>
</form>
</center>
</div>

</body>

</html>

bathurst_guy
12-21-2005, 07:12 AM
From a brief glance at your code this looks like the function you need to changefunction ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
rotate();
}
So rather than saying Start or Stop, lets change the style to start_button and stop_buttonfunction ap(text) {
document.slideform.slidebutton.style.backgroundImage = (document.slideform.slidebutton.style.backgroundImage == "start_button.gif") ? "start_button.gif" : "stop_button.gif";
rotate();
}I havnt tested the code though, so please tell me of any errors you get and we can work from there.

stunter
12-22-2005, 01:12 PM
no luck with that. I was thinking maybe both the slidebutton.value and the slidebutton.style.backgroundImage both needed to be on there but had no luck wth that either

stunter
12-22-2005, 01:23 PM
I got the original format from here http://javascript.internet.com/miscellaneous/image-slideshow.html and tried to make some mods.