Hi there
I have a requirement here to change the image that displays in an image tag x number of times, on a timer.
All images that will need to be displayed (in order) will be pulled from a database. the number of images will depend on number of records returned.
Each set of images will have only one url to be linked to.
Because of the dynamic number of images, i really need to be able to pass an array of images to a javascript function which will switch the image x times.
Below is some code which i have at present, but i have set a predermined number of parameters as images. Could someone please help me make this more dynamic? Also the below code does not work, images end up undefined, as does the url.
number of images could be 0,1,2,3,n..
// Courtesy of SimplytheBest.net
var image="";
var banners=0;
function cycle() {
if (++banners > 3) banners=1; //make dynamic
loadbanners();
document.banner1.src = image;
window.setTimeout('cycle();',7000);
}
function loadbanners(gif1, gif2, gif3)
//needs dynamic array of images here
{
if (banners==1)
{
image=gif1;
}
if (banners==2)
{
image=gif2;
}
if (banners==3)
{
image=gif3;
}
}
//-->
</script>
<script language="JavaScript1.1">
<!--
var link = ""
function urlswitch(url1) {
link = url1;
return link;
}
//-->
</script>
</head><body onLoad="window.setTimeout('cycle();',7000);(loadbanners('msn.gif', 'yahoo.gif', 'cnn.gif'));(urlswitch('<a href=" onclick="this.href=urlswitch()">
<img width="100" height="50" border="0" src="cnn.gif" name="banner1"></a>
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!
I have a requirement here to change the image that displays in an image tag x number of times, on a timer.
All images that will need to be displayed (in order) will be pulled from a database. the number of images will depend on number of records returned.
Each set of images will have only one url to be linked to.
Because of the dynamic number of images, i really need to be able to pass an array of images to a javascript function which will switch the image x times.
Below is some code which i have at present, but i have set a predermined number of parameters as images. Could someone please help me make this more dynamic? Also the below code does not work, images end up undefined, as does the url.
number of images could be 0,1,2,3,n..
// Courtesy of SimplytheBest.net
var image="";
var banners=0;
function cycle() {
if (++banners > 3) banners=1; //make dynamic
loadbanners();
document.banner1.src = image;
window.setTimeout('cycle();',7000);
}
function loadbanners(gif1, gif2, gif3)
//needs dynamic array of images here
{
if (banners==1)
{
image=gif1;
}
if (banners==2)
{
image=gif2;
}
if (banners==3)
{
image=gif3;
}
}
//-->
</script>
<script language="JavaScript1.1">
<!--
var link = ""
function urlswitch(url1) {
link = url1;
return link;
}
//-->
</script>
</head><body onLoad="window.setTimeout('cycle();',7000);(loadbanners('msn.gif', 'yahoo.gif', 'cnn.gif'));(urlswitch('<a href=" onclick="this.href=urlswitch()">
<img width="100" height="50" border="0" src="cnn.gif" name="banner1"></a>
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!