Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Randomise and Go to last???

    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.

    Code:
    <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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,082
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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.

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok thanks alot for your help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •