View Full Version : Choosing a specific picture from an array

08-05-2002, 08:58 PM
I'm trying to make a picture gallery. Here's how I'm trying to make it:
On the main page is a number of thumbnails.
If you click on one it will open a new window and display the full image.
In that window will be a forward and backward button that moves through the other images.
I've got all that down, but my question is, how would I choose a picture from the array to display first?
Say I have two pictures in the thumbnail index. I Click on the first one and a popup window comes up and it displays the first image in the array. How would I make it so when I click on the second image the pop up window will display the second image in the array?


This is a little mockup I've done. I use the onClick="window.open();" command to open the popup, which is targeted to Page001.htm. Page001.htm is the page that has the array in it. Thanks for any help. =)

08-05-2002, 11:01 PM
looks just fine to me. Did you fix it?

08-06-2002, 03:14 AM
The slide show works fine, yes. I just don't know how to open the slide show to a specific picture. Does this make sense, what I'm trying to explain? Please let me know. Thanks

08-06-2002, 06:02 AM
use the query string to pass a param, and extract that data for your first() function.

then, in the popup....

var firstSlide = parseInt(top.location.search.substring(1));
etc. etc.

See if you can get it from here...

08-10-2002, 05:56 AM
Sorry... I can't quite get it to work... do you think you could explain a little more? Thanks

08-10-2002, 06:49 AM
Use an onLoad triggered function that initializes the picture instead of hardcoing picture1 into the HTML. this function would use the variable I set in my last post.

08-10-2002, 06:23 PM
I think I'm getting it...
I really don't know much of this code since most of it isn't mine, but this is what I did...

onLoad="javascript:var firstSlide = parseInt(top.location.search.substring(1));"

I put that in the body tag replacing onLoad="javascript:first();"

and in the image tag I replaced id="thepic" and src="thepic" with id="firstslide" and src="firstslide"

I know I'm doing something wrong because I'm totally unskilled with Javascript. =P

08-12-2002, 07:12 AM
Apologies. I was operating under the assumption that you coded the slideshow. Change up first() to look like this:
function first()
curindex = firstSlide;
} And just make sure the firstSlide var gets declared at the top with the other globals.

08-16-2002, 04:27 AM
I'm having a little trouble with this myself...

I get the error firstslide is undefined, I'm curious if I defined it at the wrong spot. I put it where all the other variables were being defined, in function showcurrent.

Here is the page:


You guys know better than me. I appreciate your help.

08-16-2002, 07:21 AM
ya, firstSlide has to be global, and declared before any functions use it. Put it here

var curindex=0;
var gap=4;
var firstSlide = parseInt(top.location.search.substring(1)); And make sure not to re-declare it in the showcurrent() function.