Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

RE: FN-FORUM: classic asp - random numbers problem

date posted 18th May 2007 19:23

Chris wrote:
> I'm trying to prevent the quote_query script from picking the same=20
> random number twice in a row, in fact ideally I'd like it to avoid=20
> picking any of the previous 5 random numbers. To do this I've=20
> attempted to use session cookies to keep track of the previous=20
> random numbers.=20

Richard wrote:
> Maybe the best way would be to put the numbers 1 to 28 in a random=20
> order and then move along the randomised list in order?

JavaScript provides a simple method for randomising the order of an =
Array,
as suggest by Richard. You could use some server-side JScript to handle =
the
re-ordering on VBScript's behalf:

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=3D89

Alternatively, a fairly straight-forward means of randomising a VBScript
Array is given in the article below - I'd suggest just using the loop =
that
creates the random NumList:

=09
http://www.aspin.com/func/content-review?tree=3Daspin/tutorial/variable&i=
d=3D568
8010&rid=3D

Whichever method you use, store the randomly organised number list in a
Session variable, use a second Session var to keep track of your =
position in
the list and increment it each time you display the banner (looping back =
to
start when reach end).

This approach would mean all banners get displayed, in a random order, =
but
would mean that the banners appear in the same order the second time =
around.

Cheers, Ben

--
Ben Johnson, Neogic Web Solutions
// design . development . managed hosting

w | http://www.neogic.com
t | +44 (0)1242 808 262
e | [EMAIL REMOVED]







Messages by Day
May 31st 2007
May 30th 2007
May 29th 2007
May 28th 2007
May 27th 2007
May 26th 2007
May 25th 2007
May 24th 2007
May 23rd 2007
May 22nd 2007
May 21st 2007
May 20th 2007
May 19th 2007
May 18th 2007
May 17th 2007
May 16th 2007
May 15th 2007
May 14th 2007
May 13th 2007
May 12th 2007
May 11th 2007
May 10th 2007
May 9th 2007
May 8th 2007
May 7th 2007
May 6th 2007
May 5th 2007
May 4th 2007
May 3rd 2007
May 2nd 2007
May 1st 2007


Messages by Month
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000