Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple random, linked, images... no repeats

    I have found a code that will work fine for my random linked image...
    Code:
    <% 
    
    limit=7
    redim link(limit) 
    redim image (limit)
    
    
    link(1)="http://www.yahoo.com"
    image(1)="http://us.yimg.com/images/yahoo.gif"
    
    link(2)="http://www.excite.com"
    image(2)="http://www.excite.com/mesp/images/excite/new_logo-180.gif"
    
    link(3)="http://www.lycos.com"
    image(3)="http://a284.g.akamai.net/7/284/987/000/lygo.com/ly/i/lyguide.gif"
    
    link(4)="http://www.cnet.com"
    image(4)="http://cnet.com/Images/Headers/cnet-1-title.gif"
    
    link(5)="http://www.go.com"
    image(5)="http://www.go.com/images/hp/go_logo_121_58.gif"
    
    link(6)="http://www.webcrawler.com"
    image(6)="http://webcrawler.com/img/web/hdr/home_header.gif"
    
    link(7)="http://www.go.com"
    image(7)="http://www.go.com/images/hp/go_logo_121_58.gif"
    
    
    randomize
    random=int(rnd*limit)+1
    
    
    %>
    <center> 
    <a href="<%= link(random) %>">
    <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?

  • #2
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Something like this...

    <%

    limit=7
    redim link(limit)
    redim image (limit)


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

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

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

    link(4)="http://www.cnet.com"
    image(4)="http://cnet.com/Images/Headers/cnet-1-title.gif"

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

    link(6)="http://www.webcrawler.com"
    image(6)="http://webcrawler.com/img/web/hdr/home_header.gif"

    link(7)="http://www.go.com"
    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>
    <a href="<%= link(Num1) %>">
    <img src="<%= image(Num1) %>" border="0"></a>
    <a href="<%= link(Num2) %>">
    <img src="<%= image(Num2) %>" border="0"></a>
    <a href="<%= link(Num3) %>">
    <img src="<%= image(Num3) %>" border="0"></a>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •