• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Need to link to a specific image in a java array

Joined
Dec 14, 2006
Messages
59
Right now I have a very simple Javascript image array

<script language="JavaScript"<!--
ImageNames = new Object();
ImageNames.length = 56;
for (counter = 0; counter < 57; counter++) {
file_number = counter + 1;
file_name = ("image" + file_number + ".jpg");
ImageNames[counter] = file_name;
}
//--></script>
<script language="JavaScript">
<!--
which_image_loaded = 0;

function changeImage(direction) {
which_image_loaded += direction;
if (which_image_loaded < 0)
which_image_loaded = 56;
if (which_image_loaded > 56)
which_image_loaded = 0;
if (document.images)
document.myimage.src = ImageNames[which_image_loaded];
}

function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>

along with an image on the page and buttons that control the script

<a href="javascript:changeImage(-1)">

along with

<img src="image1.jpg">

This is for a web gallery of photographs, basically a picture in the center with a Back and Forward button to cycle through them. I also have an actual thumbnail gallery though, as I want people to be able to load the images they want without having to manually cycle through all of them. How then would I link to a specific image in this javascript array from a separate Web Gallery page?

I hope this is the right place to ask this, any help would be appreciated :)
 
FWIW, you can prob replace:

which_image_loaded += direction;
if (which_image_loaded < 0)
which_image_loaded = 56;
if (which_image_loaded > 56)
which_image_loaded = 0;

with:

which_image_loaded=(which_image_loaded+direction)%57

which will give you a number between 0 and 56 (the remainder when dividing the result by 57)

How are you generating the thumbnails? do the numbers in the thumbnails match the numbers in the gallery?
 
Back
Top