PDA

View Full Version : Multiple random, linked, images... no repeats

thewillum
04-26-2006, 03:10 AM
I have found a code that will work fine for my random linked image...
<%

limit=7
redim image (limit)

image(1)="http://us.yimg.com/images/yahoo.gif"

image(2)="http://www.excite.com/mesp/images/excite/new_logo-180.gif"

image(3)="http://a284.g.akamai.net/7/284/987/000/lygo.com/ly/i/lyguide.gif"

image(5)="http://www.go.com/images/hp/go_logo_121_58.gif"

image(7)="http://www.go.com/images/hp/go_logo_121_58.gif"

randomize
random=int(rnd*limit)+1

%>
<center>
<img src="<%= image(random) %>" border="0"></a>
But what I need is three random linked images on my page, making sure that no two images are the same...

help?

Archangel
04-28-2006, 04:54 PM
Something like this...

<%

limit=7
redim image (limit)

image(1)="http://us.yimg.com/images/yahoo.gif"

image(2)="http://www.excite.com/mesp/images/excite/new_logo-180.gif"

image(3)="http://a284.g.akamai.net/7/284/987/000/lygo.com/ly/i/lyguide.gif"

image(5)="http://www.go.com/images/hp/go_logo_121_58.gif"

image(7)="http://www.go.com/images/hp/go_logo_121_58.gif"

randomize
Num1=int(rnd*limit)+1

Num2=int(rnd*limit)+1

If Num2 = Num1 Then
Do While Num2 = Num1
Num2=int(rnd*limit)+1
Loop
End If

Num3=int(rnd*limit)+1

If Num3 = Num2 or Num3 = Num1 Then
Do While Num3 = Num2 OR Num3 = Num1
Num3=int(rnd*limit)+1
Loop
End If

%>
<center>