Jump to content

[SOLVED] preloader function help


jdubwelch

Recommended Posts

i have 32 images in a folder.  they're named: 0.gif, 1.gif, 2.gif,..., 30.gif, 31.gif

 

I want to preload all those images.  Preloader is my function that doesn't work and makes my other function "setWinner" to not work.

 

   <script language="JavaScript" type="text/javascript">
<!--
function setWinner(clickedObjId,row)
{

	document.getElementById('row'+row).innerHTML = '<div align="center"><img src="team_logos/' + clickedObjId + '.gif" width="80" height="80" /></div>';
	document.getElementById('winner'+row).value = clickedObjId;

}

function preloader () {

	imageObj = new Image();

	for(var i=0, i<=31; i++) 
	{
		imageObj.src = 'team_logos/' + i + '.gif';
	}

}

// -->
</script>

Link to comment
https://forums.phpfreaks.com/topic/80382-solved-preloader-function-help/
Share on other sites

try this and see if it correct the issue:

 

   <script language="JavaScript" type="text/javascript">
<!--
function setWinner(clickedObjId,row)
{

	document.getElementById('row'+row+'').innerHTML = '<div align="center"><img src="team_logos/' + clickedObjId + '.gif" width="80" height="80" /></div>';
	document.getElementById('winner'+row+'').value = clickedObjId;

}

function preloader () {

	imageObj = new Image();

	for(var i=0, i<=31; i++) 
	{
		imageObj.src = 'team_logos/' + i + '.gif';
	}

}

// -->
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.