Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Randomizing question.....
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

bobby131313
Senior Member

USA
1163 Posts

Posted - 04 June 2007 :  17:06:30  Show Profile  Visit bobby131313's Homepage

I'm putting some paid ads on my site and I would like the order of them to randomize each page load. I've googled this off and on for a few days and can't seem to find anything.

I found a code that will select from a group and randomly select one to display which I made work for now...


<%
RANDOMIZE
LowestNumber = 1
HighestNumber = 4
RandomNumber = INT((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)
%> 
<%
RANDOMIZE
LowestNumber = 1
HighestNumber = 4
RandomNumber = INT((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)
SELECT CASE RandomNumber
CASE "1"%>
<!--#include virtual="/includes_menu/inc_tla_rotate1.asp" -->
<%CASE "2"%>
<!--#include virtual="/includes_menu/inc_tla_rotate2.asp" -->
<%CASE "3"%>
<!--#include virtual="/includes_menu/inc_tla_rotate3.asp" -->
<%CASE "4"%>
<!--#include virtual="/includes_menu/inc_tla_rotate4.asp" -->
<%END SELECT%>


In each of the includes I have all 4 ads set up with a different one on top, so it works, but seems like well, the long way.

Is there some easy way to put the 4 ads in the same file and have them all display, but in a random order each time? So I can do away with all the includes?

I hope I explained that well enough.

Thanks for any help in advance.


Switch the order of your title tags

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 04 June 2007 :  17:40:43  Show Profile  Send ruirib a Yahoo! Message
I probably would define an string array, use the starting random Number as the starting array position and then just navigate the array:

HighestNumber = 3
Dim ads(3)

ads(0)="here goes the html for each ad"
ads(1)="..."
(...)

RANDOMIZE
LowestNumber = 0

RandomNumber = INT((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)

count = 0 

while int <= HighestNumber

   Response.Write ads(RandomNumber)

   RandomNumber = RandomNumber + 1
   if RandomNumer > HighestNumber then RandomNumber = 0
   count = count +1

Wend




Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 04 June 2007 :  19:08:11  Show Profile  Visit bobby131313's Homepage


Thanks Rui, I will play with it tomorrow.


Switch the order of your title tags
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07