View Single Post
Old 08-06-2006, 20:27   #1
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
Slight probs with a javascript

hey people,

I have got a small page that I am showing some pics that I took today, when I was out cycling over the local hills.

I have the page working fine, like a back and forward button and the images smaller than they should be so they fit on the screen better than when they were big.

this part works fine.

but I also want to put the big files on show as well if someone clicks the smaller image.

now, there is only one page so I am using javascript to incrememnt a number and change the picture accordingly, this part is fine.

but I am trying to get the image and find the same one but in larger size,

does this make sense?

I have a cycle folder with the html file and the smaller images, and I have another folder (Large) with the larger images.

here is the code but the red is the problems:

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("theBigImg").src = theBigPic;
        document.getElementById("theBigImg").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="Large/pic1.JPG" id="theBigImg" onClick="showBigPic()">
        <img src="pic1.JPG" id="theImg">
    </a>
</BODY>
</HTML>
ik
ikthius is offline   Reply With Quote