[thelist] VBScript output randomizer
Ken Schaefer
Ken at adOpenStatic.com
Tue Aug 11 22:21:34 CDT 2009
The variable "touse" holds a value from 1 -> 4
You want a random element from an array numbered from 0 -> 3.
So, we will subtract 1 from the value of touse, and get that element from the array.
Try this in a web page:
<%
' Put Bill's code here to generate the random value stored in touse
Response.Write("Current value of touse is: " & touse & "<br />" & vbCrLf)
newTouse=touse-1
Response.Write("Subtracting 1 from touse. New value is: " & newTouse & "<br />" & vbCrLf)
Response.Write("Getting this element from array. Value is: " & dancer(newTouse) & "<br />" & vbCrLf)
%>
-----Original Message-----
From: thelist-bounces at lists.evolt.org [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Jenni Beard
Sent: Wednesday, 12 August 2009 5:31 AM
To: thelist at lists.evolt.org
Cc: thelist at lists.evolt.org
Subject: Re: [thelist] VBScript output randomizer
Hi Bill, and thanks for the reply. One thing I do not understand from this, is how it ties in to the array I've already created:
<%
Dim dancer(3)
dancer(0)="#dancer1"
dancer(1)="#dancer2"
dancer(2)="#dancer3"
dancer(3)="#dancer4"
%>
Or, if I've not done the array correctly, how the code below will be written to tie it into the images that need to randomize. Help please?
Thanks!!
Jenni
-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Brian Cummiskey
Sent: Monday, August 10, 2009 7:51 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] VBScript output randomizer
Hi Jenni,
I would do something like this:
<%
Function RandomNumber(intHighestNumber)
Randomize
RandomNumber = Int(intHighestNumber * Rnd) + 1 End Function
'if you have 4 images, you would call it like this:
touse = RandomNumber(4)
%>
Then, touse will hold a value of 1,2,3, or 4.
using your css rules pre-defined, you can simply output like this:
<div class="dancer" id="dancer<%= touse %>"></div>
More information about the thelist
mailing list