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). 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"
"<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
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)
</script>
</head>
<body>
<img name='image1' src=''><br />
<img name='image2' src=''><br />
<select name='pictureChanger' onchange='updatePictures(this.value);'>
<option value='carPics'>cars</option>
<option value='vacationPics'>vacation</option>
</select>
</body>
</html>
I have this so far but it doesn't work...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
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)
</script>
</head>
<body>
<img name='image1' src=''><br />
<img name='image2' src=''><br />
<select name='pictureChanger' onchange='updatePictures(this.value);'>
<option value='carPics'>cars</option>
<option value='vacationPics'>vacation</option>
</select>
</body>
</html>