I've got a photo gallery on my website, but it seems to glitch at case 3 in my prevPic function. Instead of going backward, it goes forward. In each case, I want it to decrease the imgNum and show the previous picture. Here is some code:
function prevPic(){
/*imgNum = imgNum - 1;
if(imgNum<=1){
imgNum = 1;
groupNum = groupNum - 1;
}*/
switch(imgNum){
case 1:
if(groupNum==1){
document.getElementById("full").src="images/tanks2.jpeg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}else{
document.getElementById("full").src="images/tanks3.jpg";
document.getElementById("bar1").src="images/bar.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}
imgNum=0;
break;
case 2:
if(groupNum==1){
document.getElementById("full").src="images/tanks2.jpeg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}else{
document.getElementById("full").src="images/tanks4.jpg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}
imgNum=1;
break;
case 3:
if(groupNum==1){
document.getElementById("full").src="images/house1.jpeg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}else{
document.getElementById("full").src="images/motors.jpg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}
imgNum = 2;
break;
case 4:
if(groupNum==1){
document.getElementById("full").src="images/house2.jpeg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}else{
document.getElementById("full").src="images/controls.jpg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}
imgNum = 3;
break;
case 5:
if(groupNum==1){
document.getElementById("full").src="images/platform1.jpeg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}else{
document.getElementById("full").src="images/motors2.jpg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar.jpg";
document.getElementById("bar6").src="images/bar2.jpg";
}
imgNum = 4;
break;
case 6:
if(groupNum==1){
document.getElementById("full").src="images/fence.png";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar.jpg";
}else{
document.getElementById("full").src="images/field.jpg";
document.getElementById("bar1").src="images/bar2.jpg";
document.getElementById("bar2").src="images/bar2.jpg";
document.getElementById("bar3").src="images/bar2.jpg";
document.getElementById("bar4").src="images/bar2.jpg";
document.getElementById("bar5").src="images/bar2.jpg";
document.getElementById("bar6").src="images/bar.jpg";
}
imgNum = 5;
break;
}
document.getElementById("numfield").value=imgNum;
}
`