Forum Moderators: open
my question references the following script below.
I want to call the array from multiple positions on the webpage.
I tried pasting the following in different tables but when it calls, all are the same links/images.
<script>
var cont=titles[MachoManRandomSavage]+"<br>"+descriptions[MachoManRandomSavage]
cont+="<br><a href='"+urls[MachoManRandomSavage]+"' target='_blank'>"
cont+="<img src='"+image[MachoManRandomSavage]+"'><br>"
cont+="<br><a href='"+urls[MachoManRandomSavage]+"' target='_blank'><b>Preview This DVD</b></a><br>"
document.write(cont)
</script>
Is there a way to call the same array from multiple postions on the webpage and have each position be random?
SCRIPT IN QUESTION:
<script>
//Random link plus text description script
//specify total # of random links
var totallinks=33
var image=new Array(totallinks)
var urls=new Array(totallinks)
var descriptions=new Array(totallinks)
var titles=new Array(totallinks)
image[0]="http://www.dvd.com/dvd.jpg"
urls[0]="http://www.dvd.com"
descriptions[0]="Recent Release"
titles[0]="<b>Troy</b>"
image[1]="http://www.dvd.com/dvd.jpg"
urls[1]="http://www.dvd.com"
descriptions[1]="Recent Release"
titles[1]="<b>Day After Tomorrow</b>"
image[2]="http://www.dvd.com/dvd.jpg"
urls[2]="http://www.dvd.com"
descriptions[2]="Will Smith"
titles[2]="<b>I,Robot</b>"
image[3]="http://www.dvd.com/dvd.jpg"
urls[3]="http://www.dvd.com"
descriptions[3]="Dark Jedi"
titles[3]="<b>Revenge Of the Jedi</b>"
image[4]="http://www.dvd.com/dvd.jpg"
urls[4]="http://www.dvd.com"
descriptions[4]="The Fellowship"
titles[4]="<b>LORD OF THE RINGS</b>"
image[5]="http://www.dvd.com/dvd.jpg"
urls[5]="http://www.dvd.com"
descriptions[5]="THE BEGINNING"
titles[5]="<b>STARWARS</b>"
var MachoManRandomSavage=Math.floor(Math.random()*totallinks)
</script>
<script>
var cont=titles[MachoManRandomSavage]+"<br>"+descriptions[MachoManRandomSavage]
cont+="<br><a href='"+urls[MachoManRandomSavage]+"' target='_blank'>"
cont+="<img src='"+image[MachoManRandomSavage]+"'><br>"
cont+="<br><a href='"+urls[MachoManRandomSavage]+"' target='_blank'><b>Preview This DVD</b></a><br>"
document.write(cont)
</script>
Thank You
Fess