Hi guys,
I trying to get numbers from <div>'s and use them in if() commands.
I've got the number but the if() commands don't seem to be working.
Here is the code I'm using:
Thanks for your help,Code:window.onload = showPhoto var pNum = 1; // global num function showPhoto() { var pMain = document.getElementById("pMain"); // Attaching the pMain variable to the pMain div var photo = document.getElementById("photo"); // Attaching the photo variable to the photo div var photoImage = document.getElementById("photoImage"); var fade = document.getElementById("fade").style.visibility = "visible"; photo.innerHTML = pMain.innerHTML; /* Putting the HTML of the pMain into the photo */ pMain.style.visibility = "hidden"; photo.style.visibility = "visible"; photo.style.height = (photoImage.clientHeight+55)+"px"; var wWidth = document.documentElement.clientWidth; var wHeight = document.documentElement.clientHeight; photo.style.left = ((wWidth - photo.clientWidth)/2)+"px"; photo.style.top = ((wHeight - photo.clientHeight)/2)+"px"; } function nextButton() { var photo = document.getElementById("photo"); var photoImage = document.getElementById("photoImage"); var picNum = parseFloat(document.getElementById("picNum").innerHTML); var totalPics = parseFloat(document.getElementById("picNum1").innerHTML); var imageSRC = photoImage.src; var imageLength = photoImage.src.length; var imageStart = imageSRC.substring(0, (imageLength-5)); var imageEnd = imageSRC.substring((imageLength-4), imageLength); if(pic == nums) { pNum = 1; pic = 1; photoImage.src = imageStart+pNum+imageEnd; } if(pic != nums) { pic = pNum; pNum++; photoImage.src = imageStart+pNum+imageEnd; } photo.style.height = (photoImage.clientHeight+55)+"px"; document.getElementById("picNum").innerHTML = pNum; } function prevButton() { var photo = document.getElementById("photo"); var photoImage = document.getElementById("photoImage"); var picNum = document.getElementById("picNum").innerHTML; var totalPics = document.getElementById("picNum1").innerHTML; var pic = document.getElementById("pic").value; var nums = document.getElementById("nums").value; var imageSRC = photoImage.src; var imageLength = photoImage.src.length; var imageStart = imageSRC.substring(0, (imageLength-5)); var imageEnd = imageSRC.substring((imageLength-4), imageLength); if(pic == 1) { pNum = nums; pic = nums; photoImage.src = imageStart+pNum+imageEnd; } if(pic != 1) { pic = pNum; pNum--; photoImage.src = imageStart+pNum+imageEnd; } photo.style.height = (photoImage.clientHeight+55)+"px"; document.getElementById("picNum").innerHTML = pNum; }
tecmeister.


Reply With Quote
Bookmarks