...

View Full Version : Randomise and Go to last???



wakuwuaku
01-26-2009, 06:31 PM
The following is the code I am using fro a slideshow.

So far the slideshow begins at img1 it has a next and previous button and a got to beginning button.

I would like there to be an option to randomise the order and a button to go to end could someone show my code could be edited to achiev this.


<td align="center" width="100%"><img src="img1.jpg" name="photoslider"></td>
</tr>

<tr>
<td width="100%">
<div align="center">

<script type= "text/javascript">

var photos=new Array();
var which=0;

photos[0]="img1.jpg"
photos[1]="img2.jpg"
photos[2]="img3.jpg"
photos[3]="img4.jpg"
photos[4]="img5.jpg"
photos[5]="img6.jpg"

function backward(){
if (which>0){
window.status='';
which-- ;
document.photoslider.src=photos[which];
}
}

function forward(){
if (which<photos.length-1){
which++ ;
document.photoslider.src=photos[which];
}
else window.status='End of gallery';
}

</script>

<br>
<input type="button" value="&lt;&lt; Back" name="B2" onClick="backward()"> &nbsp &nbsp <input type="button" value="Next &gt;&gt;" name="B1" onClick="forward()"><br><br>

<a href="#" onClick="which=1;backward();return false"><font face="Arial, Helvetica" color="#0000FF"><small><b>Go back to the start</b></small></a></p>
</center></div>

Thanks
Oli

Philip M
01-26-2009, 06:44 PM
To go to the end:-

<a href="#" onClick="which=photos.length-2; forward(); return false"><font face="Arial, Helvetica" color="#0000FF"><small><b>Go to the last image</b></small></a></p>

This script does not lend itself to randomisation - it is supposed to show the images in the predetermined order. You should have asked for that in the first place.

wakuwuaku
01-26-2009, 07:26 PM
Ok thanks alot for your help



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum