Random link
I got a mail from a developer who wanted To display
a list of links where the order where random. And it
puzzled Me For a While how To accomplish this. So
I started coding And soon I had this code:
<%
'Make link Array
Dim LinkArray(4,2)
'Putting In the links into the Array
'If you want, you can read those links from
'a Text file Or a db. If you want more links, just
'increase the size of the Array
LinkArray(0,1)=""http://haneng.com""
LinkArray(0,2)=""A cool ASP site: haneng.com!""
LinkArray(1,1)=""http://www.news.com""
LinkArray(1,2)=""Computer news from news.com!""
LinkArray(2,1)=""http://www.yahoo.com""
LinkArray(2,2)=""Do you Yahoo?""
LinkArray(3,1)=""http://www.hotbot.com""
LinkArray(3,2)=""My favorite search engine: hotbot""
LinkArray(4,1)=""http://www.gamecenter.com""
LinkArray(4,2)=""Visit Gamecenter""
%>
<HTML>
<BODY>
<%
Randomize
NotChooseUsAgain = ""#""
For i=0 To UBound(LinkArray)
While Not OK
RandomVar = Int(Rnd * (UBound(LinkArray)+1))
If InStr(NotChooseUsAgain,""#"" & RandomVar & ""#"")=0
Then
OK = True
NotChooseUsAgain = NotChooseUsAgain & RandomVar &
""#""
End If
Wend
%>
<A HREF=""<%=LinkArray(RandomVar,1)%>"">
<%=LinkArray(RandomVar,2)%></A><BR>
<%
OK = False
Next
%>
</BODY>
</HTML>
It works, but Is there an easier way??
Please drop Me line With your opinion:
webmaster@haneng.com
What you'd want the script For? I'm Not sure,
but it could be nice If you have a list of links
To all your friends On your page. Then they won't
be angry If their site wasn't at the top.
"![]()