Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 01-23-2010, 04:31 PM   #1
Join Date: Feb 2009
Posts: 40
Default javaScript simple next button gallery

Hi there, does anyone know the best way to code a gallery where its just one image showing (of 6) and when you click the next/back button it keeps moving through the pictures?

Have been playing with the code below but its from an old old tutorial so I dont know if its compliant, cant get it working anyway. My images are names image1.jpg through to image6.jpeg

Can anyone see whats wrong with it, or surgest another option?

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="JavaScript"><!--
which_image_loaded = 0;
ImageNames = new Object();
ImageNames.length = NUMBER_OF_IMAGES - 1;
for (counter = 0; counter < NUMBER_OF_IMAGES; counter++){
file_number = counter + 1;
filename = ("image" + file_number + ".jpg");
ImageNames[counter] = filename;
function changeImage(direction) {
which_image_loaded += direction;
if (which_image_loaded < 0)
which_image_loaded = NUMBER_OF_IMAGES - 1;
if (which_image_loaded == NUMBER_OF_IMAGES)
which_image_loaded = 0;
if (document.images)
document.myimage.src = ImageNames[which_image_loaded];
<div><a href="javascript:changeImage(-1)"><img src="images/temp/arrowback.gif" width="28" height="18" /></a>
<a href="javascript:changeImage(1)"><img src="images/temp/arrownext.gif" width="28" height="18" /></a>
<div><img src="images/temp/image1.jpg" width="300" height="400" /></div>

jax23 is offline   Reply With Quote
Old 01-23-2010, 05:56 PM   #2
domedia's Avatar
Join Date: Dec 2003
Posts: 9,730

IF it's too old, check out jQuery and the Cycle plugin.
domedia is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 09:03 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com