View Full Version : Image gallery array help (code included)

05-06-2004, 04:13 PM
Hi there. I'm trying to build a simple image gallery where I can change multiple images based on selecting a top from a dropdown list (ie. selecting a submitting 'cars' from the dropdown list populates the images table with pictures of cars and so on). Plus I want to populate a 'href' for each picture. I've been looking around and haven't found anything quite suitable that doesn't rely on asp or refreshing the page. Any help would be much appreciated.

I have this so far but it doesn't work...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

var imageTags;
var maxPics = 0;
var carPics = new Array("red.gif");
var vacationPics = new Array("green.gif"");

function determineMaxPics()
for(var i=0; i<pictureChanger.length; i++)
var numPics = eval(pictureChanger.value).length;
if(numPics > maxPics)
maxPics = numPics;
}//end for
}//end determineMaxPics()

function updatePictures(arrayName)
var i=0;
var picArray = eval(arrayName);
for(; i<picArray.length; i++)
imageTags.src = picArray;

for(; i<maxPics; i++)
imageTags.src = ""; //empties trailing picture tags
}//end updatePictures(var)



<a href="some generated value"><img name='image1' src=''></a><br />
<a href="some generated value"><img name='image2' src=''></a><br />
<select name='pictureChanger' onchange='updatePictures(this.value);'>
<option value='carPics'>cars</option>
<option value='vacationPics'>vacation</option>