Preload and Print Javascript Images

Status
Not open for further replies.

Mindverse

Smack-Fu Master, in training
93
I am doing my first web page for a person and they want to be able to upload pictures. As long as every picture they uploaded ended in .GIF and number the images i.e. first image is 1.gif, then 2.gif, 3.gif, etc.. Anyway here is the code I made to do that:

<img src="1.gif" width="33" height="32">
<script lanuage="javascript" type="text/JavaScript">





function DoLoad(){
var Image_Array=new Array;
for(i=1; i<100; i++){
var Loc=i+".gif";
var an_image=new Image();
an_image.src=Loc;
if(an_image.complete){
Image_Array=an_image.src;
}
}
Pload(Image_Array);
}





function Pload(an_array){
for(j=1; j<an_array.length; j++){
var another_image=new Image();
another_image.src=an_array[j];
WriteImage(another_image.src);
}
}





function WriteImage(I_mage){
document.writeln('<img src="'+I_mage+'">');
}
DoLoad();
</script>






The problem is that when I load the page it only loads two of the pictures no matter how many are actually on the server. If you hit refresh more will appear until it reaches the highest number image on the server i.e. 7.gif.





How do I make it so you don't have to click refresh and they all come up first time?? -- :eek: --





(if you don't understand question plz leave a note asking me to rephrase) -- :) --
 
Status
Not open for further replies.