View Full Version : Random adds


joshg678
02-28-2003, 05:07 PM
I need some help with some programming this script. What i want to do is have a random pick show up and have a link for it but i wand to be able to have different links for different ones. The script i have i listed below.



<script language="javascript">
<!--
function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish

myimages[1]="http://www.bravenet.com/brpics/affiliate/br11.gif"
myimages[2]="http://images.bravenet.com/affiliate/pub/br1.gif"
myimages[3]="http://images.bravenet.com/affiliate/pub/br16.gif"
myimages[4]="http://images.bravenet.com/affiliate/pub/br13.gif"
myimages[5]="http://images.bravenet.com/affiliate/pub/br15.gif"

//specify corresponding alts below
var alttext=new Array()

alttext[1]="bravenet"
alttext[2]="bravenet"
alttext[3]="bravenet"
alttext[4]="bravenet"
alttext[5]="bravenet"

//specify corresponding alts below
var http=new Array()

http[1]="http://www.bravenet.com/?afilid=1216368232"
http[2]="http://www.bravenet.com/?afilid=1216368232"
http[3]="http://www.bravenet.com/?afilid=1216368232"
http[4]="http://www.bravenet.com/?afilid=1216368232"
http[5]="http://www.bravenet.com/?afilid=1216368232"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'" border=1 alt="'+alttext[ry]+'">')
document.write('<a href="'+http[ry]+'">')
}
random_imglink()
//-->
</script>



this script works except for the hyperlink. Please help me out. Thanks

joshg678
03-01-2003, 04:22 AM
i fixed it, the working code is listed below



<!-- RANDOM PICTURES AND ADDS MADE MY JOSH GOULD AT http://www.geocities.com/joshg678-->
<script language="javascript">
<!--
function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish

myimages[1]="http://www.bravenet.com/brpics/affiliate/br11.gif"
myimages[2]="http://images.bravenet.com/affiliate/pub/br1.gif"
myimages[3]="http://images.bravenet.com/affiliate/pub/br16.gif"
myimages[4]="http://images.bravenet.com/affiliate/pub/br13.gif"
myimages[5]="http://images.bravenet.com/affiliate/pub/br15.gif"

//specify corresponding alts below
var alttext=new Array()

alttext[1]="bravenet"
alttext[2]="bravenet"
alttext[3]="bravenet"
alttext[4]="bravenet"
alttext[5]="bravenet"

//specify corresponding alts below
var http=new Array()

http[1]="http://www.bravenet.com/?afilid=1216368232"
http[2]="http://www.bravenet.com/?afilid=1216368232"
http[3]="http://www.bravenet.com/?afilid=1216368232"
http[4]="http://www.bravenet.com/?afilid=1216368232"
http[5]="http://www.bravenet.com/?afilid=1216368232"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href="'+http[ry]+'"><img src="'+myimages[ry]+'" border=1 alt="'+alttext[ry]+'"></a>')
}
random_imglink()
//-->
</script>
<!-- END RANDOM PICTURES AND ADDS MADE MY JOSH GOULD AT http://www.geocities.com/joshg678-->



if you all want to use just leave the message saying that i made. Thanks

Alcy
03-01-2003, 04:22 AM
Try changing this bit:
document.write('<img src="'+myimages[ry]+'" border=1 alt="'+alttext[ry]+'">')
document.write('<a href="'+http[ry]+'">')

To this :D:
document.write('<a href="'+http[ry]+'"><img src="'+myimages[ry]+'" border=1 alt="'+alttext[ry]+'"></a>')

joshg678
03-01-2003, 04:31 AM
Thats what i just and it works now. I did find it out on my own But thanks a bunch