At 02:54 PM 9/19/00 +0100, you wrote:
>Works for me from 1 to 7
>but you should change the code  to
>
>
><cfparam name="imageswap" default="#randrange(1,7)#">
>
><cfoutput>
><img src="home_photo#imageswap#.jpg">
></cfoutput>

I've actually done something similar with a database so whoever managed the 
rest of the content could add new images, remove images, etc. This can also 
handle alt tags and such.

It went something like this:
<cfset randomimage=RandRange(1,#QueryName.RecordCount#)>
<cfoutput>
<img src="#QueryName.ImageFieldName[randomimage]#" 
alt="#QueryName.AltFieldName[randomimage]#">
</cfoutput>

I think that's right. I don't have the code to look at.



>also read up on Randomize(number)
>
>
>~Justin
>
>
>----- Original Message -----
>From: "Les Mizzell" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Tuesday, September 19, 2000 2:28 PM
>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/cf-talk@houseoffusion.com/
> > 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/cf-talk@houseoffusion.com/
>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/cf-talk@houseoffusion.com/
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.

Reply via email to