Hallo Les,
the problem is the randrange function is not really
a random function. It can happen you will get the same
number more than 5-10 times.
If you will get the range set to 1000 (like (1,1000)),
your "randomness" will be better then.
Another point: don't use <if>, you can simplify your
code like that:
<cfparam name="imageswap" default="#randrange(1,7)#">
<cfoutput>
<img src="home_photo#imageswap#.jpg">
</cfoutput>
Best,
Miro.
-----Original Message-----
From: Les Mizzell [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 19, 2000 3:29 PM
To: [EMAIL PROTECTED]
Subject: [CF-Talk] Random Images
I'm using the block of code below to place a random image on a page each
time the page is loaded. However, for some reason, it only seems to swap
the first THREE images out, not all seven.
<cfparam name="imageswap" default="#randrange(1,7)#">
<cfif #imageswap# is "1">
<img src="home_photo1.jpg">
<cfelseif #imageswap# is "2">
<img src="home_photo2.jpg">
<cfelseif #imageswap# is "3">
<img src="home_photo3.jpg">
<cfelseif #imageswap# is "4">
<img src="home_photo4.jpg">
<cfelseif #imageswap# is "5">
<img src="home_photo5.jpg">
<cfelseif #imageswap# is "6">
<img src="home_photo6.jpg">
<cfelseif #imageswap# is "7">
<img src="home_photo7.jpg">
</cfif>
I could do this with JavaScript instead, but hell, it's close to 50 total
lines of code by the time you're done. Is there any way to get it a little
more "random" and show all seven images instead of just the first three like
it's doing?
Or....am I a total idiot and have a simple syntax error I'm just not seeing
here?
Les Mizzell
***********
Some people say I'm too apathetic.
But why should I care?
----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.