View Single Post
Old 08-06-2006, 22:01   #9
ikthius
Inactive
 
ikthius's Avatar
 
Join Date: Mar 2004
Location: Glasgow, Scotland
Services: anything for a new job
Posts: 4,165
ikthius is cast in bronzeikthius is cast in bronzeikthius is cast in bronzeikthius is cast in bronze
ikthius is cast in bronzeikthius is cast in bronzeikthius is cast in bronzeikthius is cast in bronzeikthius is cast in bronzeikthius is cast in bronzeikthius is cast in bronze
Re: Slight probs with a javascript

Quote:
Originally Posted by Mr_love_monkey
Quote:
Originally Posted by ikthius
clicking on the small image I get 800.

but I want to click that image to get to the bigger pic.

ik
hmm.. well that shows that you are finding the image object..

very odd.. the large image works on mine, but the paging back and forwards doesn't... hmmm
if it does not buttons do not work, change:

Code:
document.getElementById("theImg").src = theBigPic;
document.getElementById("theImg").alt = theBigPic;
to

Code:
document.getElementById("theBigImg").src = theBigPic;
document.getElementById("theBigImg").alt = theBigPic;
ik

EDIT: yip just tried it on IE and it works, but I would like it to work on FF too, as I and many other people use FF
EDIT: it now works in FF too, cheers
this is the end code to make it all work
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript">
    var numImages = 21; //change this number to the exact number of pics is taken
    var currentImage = 1;
    var imageName = "pic";
    var imageFile = ".JPG";
    var prefix = "Large/";
          
    function switchImage()
    {
        currentImage++;
        if(currentImage > numImages)currentImage = 1;
        var thePic = imageName + currentImage + imageFile;
        document.getElementById("theImg").src = thePic;
        document.getElementById("theImg").alt = thePic;
    }
    function goBackImage()
    {
        --currentImage;
        if(currentImage < 1)currentImage = numImages; 
        var thePic = imageName + currentImage + imageFile;
        document.getElementById("theImg").src = thePic;
        document.getElementById("theImg").alt = thePic;    
    }
    function showBigPic()
    {
        var theBigPic = prefix + imageName + currentImage + imageFile;
        document.getElementById("theImg").src = theBigPic;
        document.getElementById("theImg").alt = theBigPic;
    }
</script>
<style type="text/css">
body    {background-color:#000000; color:#FFFFFF; text-align:center;}
</style>
</HEAD>

<body>
<form>
<input type="button" value="Back" onClick="goBackImage()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="Forward" onClick="switchImage()"></form>
    <a href="#" id="theBigImg" onClick="showBigPic()">
        <img src="pic1.JPG" id="theImg">
    </a>
</BODY>
</HTML>
ikthius is offline   Reply With Quote