Ok I have a stupid question, I don't even have a clue, how to search for a solution.
I have the following code:
code:
function InitGallery(){
document.Thumb1.src = test[1].thumbnail.src
document.Thumb2.src = test[2].thumbnail.src;
document.Thumb3.src = test[3].thumbnail.src;
document.Thumb4.src = test[4].thumbnail.src;
document.Thumb5.src = test[5].thumbnail.src;
document.Thumb6.src = test[6].thumbnail.src;
document.Thumb7.src = test[7].thumbnail.src;
document.Thumb8.src = test[8].thumbnail.src;
}
How can I acomplish the same function using a FOR loop, Now I do understand FOR loops, and when I call the the above code from my body onLoad Event it works fine. But will need to acomplish the same function with in a loop to go any farther with my gallery script. What dont understand is how to deal with setting the "document.XXXXX.src" value with in a FOR loop.
I tried something like this:
document.Thumb(i).src = test[i].thumbnail.src;
and tried treating the 8 images similar to an array:
document.Thumb[i].src = test[i].thumbnail.src;
But I couldn't get it to work.
Could some explain or give an example on how to do this,
Here is my full code if it helps:
code:
// Add your gallery images here, up to 32 Images Total:
// Example: myRecord1 = new imgRecord (imgThumbnail, imgHighres, imgDescript);
var myPath = "Images/";
test = new Array(32);
test[0] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[1] = new imgRecord ("Event_002thumb.jpg","Event_002.jpg","My Image Description, Bla Bla Bla.");
test[2] = new imgRecord ("Event_003thumb.jpg","Event_003.jpg","My Image Description, Bla Bla Bla.");
test[3] = new imgRecord ("Event_004thumb.jpg","Event_004.jpg","My Image Description, Bla Bla Bla.");
test[4] = new imgRecord ("Event_005thumb.jpg","Event_005.jpg","My Image Description, Bla Bla Bla.");
test[5] = new imgRecord ("Event_006thumb.jpg","Event_006.jpg","My Image Description, Bla Bla Bla.");
test[6] = new imgRecord ("Event_007thumb.jpg","Event_007.jpg","My Image Description, Bla Bla Bla.");
test[7] = new imgRecord ("Event_008thumb.jpg","Event_008.jpg","My Image Description, Bla Bla Bla.");
test[8] = new imgRecord ("Event_009thumb.jpg","Event_009.jpg","My Image Description, Bla Bla Bla.");
test[9] = new imgRecord ("Event_010thumb.jpg","Event_010.jpg","My Image Description, Bla Bla Bla.");
test[10] = new imgRecord ("Event_011thumb.jpg","Event_011.jpg","My Image Description, Bla Bla Bla.");
test[11] = new imgRecord ("Event_012thumb.jpg","Event_012.jpg","My Image Description, Bla Bla Bla.");
test[12] = new imgRecord ("Event_013thumb.jpg","Event_013.jpg","My Image Description, Bla Bla Bla.");
test[13] = new imgRecord ("Event_014thumb.jpg","Event_014.jpg","My Image Description, Bla Bla Bla.");
test[14] = new imgRecord ("Event_015thumb.jpg","Event_015.jpg","My Image Description, Bla Bla Bla.");
test[15] = new imgRecord ("Event_016thumb.jpg","Event_016.jpg","My Image Description, Bla Bla Bla.");
//end of current Listing
test[16] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[17] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[18] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[19] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[20] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[21] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[22] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[23] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[24] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[25] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[26] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[27] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[28] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[29] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[30] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[31] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
test[32] = new imgRecord ("Event_001thumb.jpg","Event_001.jpg","My Image Description, Bla Bla Bla.");
function imgRecord (imgThumbnail, imgHighRes, imgDescrip){
/*Fumction builds an image record object, holding thumbnail, highres
and image Description information; and preloads the images. */
if (document.images){
//Preload Thumbnail
aThumbnail = new Image (85,60);
aThumbnail.src = (myPath + imgThumbnail);
//Preload Highres
aHighRes = new Image (320,220);
aHighRes.src = (myPath + imgHighRes);
this.thumbnail = aThumbnail;
this.highres = aHighRes;
this.descrip = imgDescrip;
}
}
function InitGallery(){
document.Thumb1.src = test[0].thumbnail.src
document.Thumb2.src = test[1].thumbnail.src;
document.Thumb3.src = test[2].thumbnail.src;
document.Thumb4.src = test[3].thumbnail.src;
document.Thumb5.src = test[4].thumbnail.src;
document.Thumb6.src = test[5].thumbnail.src;
document.Thumb7.src = test[6].thumbnail.src;
document.Thumb8.src = test[7].thumbnail.src;
document.PlaceHolder.src = test[0].highres.src;
}
jstuartj
(Edited by jstuartj on 08-09-2004 08:40)