Forum Moderators: open
<html>
<head>
<title></title>
<meta/>
<script type="text/javascript">
var elem;
function rotateimage(elem,imagelist,current,next)
{
alert(current);
parseInt(current);
imagearray=imagelist.split(",");
imagelength=imagearray.length--;
elem.src=imagearray[current];
if (next=='next') {
current--;
lastevent=function () {rotateimage(this.parentNode.parentNode.firstChild,imagelist,current,"previous");}
elem.parentNode.lastChild.firstChild.onclick=lastevent;
elem.parentNode.lastChild.firstChild.style.display='block';
current++;
if (current==imagelength)
{elem.parentNode.lastChild.lastChild.style.display='none';} else {
current++;
newevent=function () {rotateimage(this.parentNode.parentNode.firstChild,imagelist,current,"next");}
elem.parentNode.lastChild.lastChild.onclick=newevent;
}
}
if (next=='previous') {
current++;
lastevent=function () {rotateimage(this.parentNode.parentNode.firstChild,imagelist,current,"next");}
elem.parentNode.lastChild.lastChild.onclick=lastevent;
current--;
elem.parentNode.lastChild.lastChild.style.display='block';
if (current==0)
{elem.parentNode.lastChild.firstChild.style.display='none';
} else {
current--;
newevent=function () {rotateimage(this.parentNode.parentNode.firstChild,imagelist,current,"previous");}
elem.parentNode.lastChild.firstChild.onclick=newevent;
}}
}
</script>
</head>
<body>
<div><img src="" />
<div><img src="images/icons/arrowdown.gif" style="float:left" onclick=rotateimage(this.parentNode.parentNode.firstChild,"images/icons/arrow.gif,images/icons/arrowdown.gif,images/icons/arrowup.gif,images/icons/arrowdownh.gif",1,"previous") /><img src="images/icons/arrowup.gif" onclick=rotateimage(this.parentNode.parentNode.firstChild,"images/icons/arrow.gif,images/icons/arrowdown.gif,images/icons/arrowup.gif,images/icons/arrowdownh.gif",2,"next") /></div></div>
</body>
</html>
The problem is in following. Then onclick event fires it takes value from a current variable. But if i use several rotations systems current for this icon system overwriten by another currentsystem. Maybe somebody have any solutions?