Randomly Ordered ASP server side includes

Discussion in 'C#' started by indigojo, Oct 24, 2006.

  1. #1
    Hello everyone, I would like to modify the code below to bring in and randomly order 6 individual server side includes instead of the 6 tables shown below - is this possible and if so can someone offer some help on this please?

    <%
    Dim Quote(6)
    Quote(0) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#FF4500'>&nbsp;</td></tr></table>"
    Quote(1) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#336699'>&nbsp;</td></tr></table>"
    Quote(2) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#111111'>&nbsp;</td></tr></table>"
    Quote(3) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#556699'>&nbsp;</td></tr></table>"
    Quote(4) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#999999'>&nbsp;</td></tr></table>"
    Quote(5) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#444444'>&nbsp;</td></tr></table>"
    QuoteList = ""
    NumList = "|"
    Randomize
    For x = 0 to 5
    'get random number
    RndQuote = Int(Rnd * 6)
    Do Until Instr(Cstr(NumList),Cstr("|" & RndQuote & "|")) = 0
    RndQuote = Int(Rnd * 6)
    Loop
    NumList = NumList & RndQuote & "|"
    QuoteList = QuoteList & Quote(RndQuote) & "|"
    Next
    QuoteList = Left(QuoteList,Len(QuoteList)-1)
    QuoteArr = Split(QuoteList,"|")
    For x = 0 to UBound(QuoteArr)
    Response.Write QuoteArr(x)
    Next
    %>
     
    indigojo, Oct 24, 2006 IP
  2. Garve

    Garve Peon

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Garve, Oct 24, 2006 IP
  3. rkcca

    rkcca Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Put your tables in a Database and call out one using a random function

    This works in SQL server

    select top 1 * from MyTable where <column> = <parameter> order by NEWID()
     
    rkcca, Oct 24, 2006 IP