Click to See Complete Forum and Search --> : Random pic w/ correct link


Trent187
11-17-2003, 06:24 PM
On the site, I found the code for a random pic or a random pic, but what I want is a random pic that has a correct link to go with it. Like a random banner ad. I am doing a site for a class, and we are a fake company and we are using a banner ad to make money, so I need to know how to do this. Thanks.

Jona
11-17-2003, 06:30 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
&nbsp; "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Ad Rotation</title>
<script type="text/javascript">
<!--
var links = new Array("http://yahoo.com/", "http://msn.com/", "http://cnn.com/");
var imgs = new Array("yahoo.gif", "msn.gif", "cnn.gif");
var links_num = 3

function showAd(){
var rand = Math.floor(links_num*Math.random());
var link = links[rand];
var img = imgs[rand];

document.write("<a href=\""+link+"\"><img src=\""+img+"\"></a>");
}
// -->
</script>
</head><body>
<div><script type="text/javascript">
<!--
showAd();
//-->
</script></div>
</body></html>


[J]ona