PDA

View Full Version : a veryyyy basic image gallery !!


nits4u
03-26-2010, 06:24 PM
guys i tried to make a very basic image gallery, having left and right links to switch the images. thats it,

i am newbie to js, so try to do it by myself. Here is the code, which is not working:

<html>
<head>
<title></title>
</head>
<body>
<img src="" id="img" />
<a id="lt" href="" onclick="left()">left</a>
<a id="rt" href="" onclick="right()">right</a>
<script type="text/javascript">
var ary1 = ["rcurv.gif","lcurv.gif","midl.gif","plus.gif"];
var num=0;
function right(){
document.getElementById('img').src=ary1[num++];
}
function left(){
document.getElementById('img').src=ary1[num--];
}
</script>
</body>
</html>

domedia
03-26-2010, 09:18 PM
I would grab something like the jQuery Cycle plugin. Makes JS much easier for newbies.