|
|
 |
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]
|
 |
|