PDA

View Full Version : Refreshing Banners


ramandeep
11-18-2005, 03:59 PM
Hi i took a code from our forums for making refreshing banners i have just made some changes in it and its not working.

kindly figure it out ,i am totally brainless at the moment due to work load :blink:

<html><BODY>
<script LANGUAGE="JavaScript">
<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
banner="1.jpg";
width="100";
height="100";
}
if (ad==2) {
banner="2.jpg";
width="100";
height="100";
}
if (ad==3) {
banner="3.jpg";
width="100";
height="100";
}

if(ad==4){
banner="4.jpg";
width="100";
height="100";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</SCRIPT>

</body></html>

All JPG images 1,2,3,4 are in the same folder as this file.

davidj
11-21-2005, 08:09 AM
what about this


<script language="javascript">
function getaimage()
{

var rnumb = '';

var img=new Array(5)

img[0]='<img src="images/04-cupra-badge.jpg" width="200" height="282" />';

img[1]='<img src="images/04-cupra-badge2.jpg" width="200" height="282" />';

img[2]='<img src="images/04-cupra-badge3.jpg" width="200" height="282" />';

img[3]='<img src="images/04-cupra-badge4.jpg" width="200" height="282" />';

img[4]='<img src="images/04-cupra-badge5.jpg" width="200" height="282" />';

rnumb += Math.floor(Math.random()*5);
document.getElementById('images').innerHTML = img[rnumb];
}

</script>
</head>
<body onload="getaimage()">
<div id="images"></div>
</body>
</html>

Creative Insanity
11-21-2005, 08:33 AM
yeah I think dj's looks like the ticket. ;)

ramandeep
11-21-2005, 10:21 AM
Thanx mate it works now!