SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Baltimore
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text rotation on refresh

    I have a client that has an ecommerce site and they want to rotate multiple products on a refresh. I found a script that I have used in the past for rotating banners and changed up the code to include their products. The code works, the only problem, is that the rotation isn't on each refresh. It might be on the 5th or 10th refresh, sometimes longer.

    Here is the code example that I used:

    <%
    Dim LowestNumber, HighestNumber, RandomNumber
    RANDOMIZE
    LowestNumber = 1
    HighestNumber = 2
    RandomNumber = Int((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)
    %>
    %>
    <% Case 1 %>
    <a href="link1.htm"><img src="banner1.gif" border=0></a>
    <% Case 2 %>
    <a href="link2.htm"><img src="banner2.gif" border=0></a>
    <% End Select %>


    The orginial example had 5 links included at the bottom, but for what I'm trying to accomplish, I can get it done w/ 2.

    Any help would be greatly appreciated. And if anyone has used another script that would work better, that would be fine too.

    Thanks,

  2. #2
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jleggett View Post
    I have a client that has an ecommerce site and they want to rotate multiple products on a refresh. I found a script that I have used in the past for rotating banners and changed up the code to include their products. The code works, the only problem, is that the rotation isn't on each refresh. It might be on the 5th or 10th refresh, sometimes longer.

    Here is the code example that I used:

    <%
    Dim LowestNumber, HighestNumber, RandomNumber
    RANDOMIZE
    LowestNumber = 1
    HighestNumber = 2
    RandomNumber = Int((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)
    %>
    %>
    <% Case 1 %>
    <a href="link1.htm"><img src="banner1.gif" border=0></a>
    <% Case 2 %>
    <a href="link2.htm"><img src="banner2.gif" border=0></a>
    <% End Select %>


    The orginial example had 5 links included at the bottom, but for what I'm trying to accomplish, I can get it done w/ 2.

    Any help would be greatly appreciated. And if anyone has used another script that would work better, that would be fine too.

    Thanks,
    Do you think it may be a caching issue?

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Baltimore
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think that it is a caching issue, b/c I've used the exact same script for a rotating quotes and that seems to be working fine. So I'm not sure what is going on? If I do an F5, I can sometimes can get it to refresh it after about 10 times.

  4. #4
    SitePoint Wizard bronze trophy Tyssen's Avatar
    Join Date
    Oct 2005
    Location
    Brisbane, QLD
    Posts
    4,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't get why you're using a case statement. Shouldn't it just be:

    PHP Code:
     <a href="link<%=RandomNumber%>.htm">
    <
    img src="banner<%=RandomNumber%>.gif">
    </
    a

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Baltimore
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was an asp tutorial I found online, so I just used it and modified it accordingly.

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think that it is a caching issue
    Just try adding
    Response.CacheControl = "no-cache"
    to the top of the page and check =)

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Baltimore
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have added the code and it appears that it did help some, but it is still not refreshing on a frequent basis. But, I think that it is working well enough right now, that I think that everyone will be happy.

    Thanks for the help.

  8. #8
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've also found the vbscript's randomize doesn't appear so random at times. the larger the range of numbers trying to randomize the better...

  9. #9
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Agreed. Try randomizing between 1 and 100 ... 1-50 = one option, 51-100 = other option.

    However, if there are only 2 options then why not use a session variable to hold the last one shown, then toggle between them?
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

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