GFXVoid Graphic Design Forum

Remove Text Formatting
Loading...

» Online Users: 26,370

0 members and 26,370 guests
No Members online

» Site Navigation

 > FAQ

» Stats

Members: 35,442
Threads: 103,075
Posts: 826,688
Top Poster: cc.RadillacVIII (7,429)
Welcome to our newest member, Lekelindids
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    22

    Default

    This script creates a simple slideshow you can add to your web page. It lets you cycle through a collection of images. You can store the array of images on the actual web page within this script, or you can even keep the array in a separate .JS file in order to maintain it separately without changing the page.

    Code:
    <html>
    
    <head>
    
    <title>Simple Slideshow</title>
    
    <script language="JavaScript">
    <!--
    
    // Add your pictures to an array called pics
    pics = new Array();
    
    // Set the title and file location (URL) of each pics element
    // Add as many pictures as you want
    // Note that JavaScript arrays start at 0
    pics[0] = new Array("Title 1", "your_file_1_url.jpg");
    pics[1] = new Array("Title 2", "your_file_2_url.jpg");
    pics[2] = new Array("Title 3", "your_file_3_url.jpg");
    pics[3] = new Array("Title 4", "your_file_4_url.jpg");
    pics[4] = new Array("Title 5", "your_file_5_url.jpg");
    
    // Set the index of the first image (array starts at 0)
    var index = 0;
    
    // Increments the picture
    function incrementPic() {
    	index = index + 1;
    
    	if (index == pics.length) {
     *index = 0;
    	}
    	loadPic();
    
    return;
    }
    
    // Decrements the picture
    function decrementPic() {
    	index = index - 1;
    
    	if (index < 0) {
     *index = pics.length - 1;
    	}
    	loadPic();
    
    return;
    }
    
    // Loads the picture onto the page
    function loadPic() {
    	document.images["pic"].src = pics[index][1];
    	document.images["pic"].alt = pics[index][0];
    
    return;
    }
    
    // -->
    </script>
    
    </head>
    
    <body onload="loadPic();">
    
    <p><img name="pic" src="images/spacer.gif" border="0" alt="" /></p>
    <p><a href="javascript:decrementPic();">PREV</a> | <a href="javascript:incrementPic();">NEXT</a></p>
    
    </body>
    
    </html>
    See a Demo

    If there is enough interest in this sort of thing, I'll add an advanced version with automatic play/looping and drop-down menu selection of individual images.

    dmeister

  2. #2
    Join Date
    Dec 2004
    Location
    GFXVoid
    Posts
    4,412

    Default

    Thats really cool man - and ultra useful. That could help lessen the server stress / bandwith. Thanks much for the contribution!

  3. #3
    Join Date
    Mar 2005
    Location
    Montreal
    Posts
    713

    Default

    "That could help lessen the server stress / bandwith"

    TRUE ,,, thanx alot man

  4. #4
    Join Date
    Apr 2005
    Posts
    5

    Thumbs up

    how to images auto load that means continues show

Similar Threads

  1. i need an image upload script
    By Skyline in forum The Void
    Replies: 4
    Last Post: 02-20-2006, 05:17 PM
  2. Perl: Redirection Script
    By demo in forum Other Tutorials
    Replies: 2
    Last Post: 02-08-2006, 03:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBadvanced CMPS v4.1.1