Hi i am new to ‘javascript and am trying to construct an image gallery using javascript and the document.getelementbyidproperty… I have 2 questions !
here is my code at the moment.. working.
<html>
<head>
<script type=”text/javascript”>
myImages=new Array()
myImages[0]=”images/1.jpg”
myImages[1]=”images/2.jpg”
myImages[2]=”images/3.jpg”
imagecounter=myImages.length-1
i=0
function first()
{
document.getElementById(‘imageviewer’).src=myImages[0],
i=0
}
function second()
{
document.getElementById(‘imageviewer’).src=myImages[1]
i=1
}
function third()
{
document.getElementById(‘imageviewer’).src=myImages[2]
i=2
}
</script>
</head>
<body>
<center>
<form>
<img src=”images/1.jpg” width=50 height=50 onclick=”first()” >
<img src=”images/2.jpg” width=50 height=50 onclick=”second()”>
<img src=”images/3.jpg” width=50 height=50 onclick=”third()”>
</form>
<img id=”imageviewer” src=”blank.jpg” alt=”Click on an image to view details” width=”200″ height=”200″ />
</center>
</body>
</html>
QUESTION 1
Is there any way to create a loop for the functions i have created. i.e. if i have 3 images i need 3 functions, if i had 10 images i need 10 functions. Using a loop of some sort is it possible to create 1 function regardless of how many images i have.
QUESTION 2
I would like to have information about the image come up next to it… what would be the best way to implement this……
Thanx in advance for any help……..
Cheers.. ev