Solved

Problem with RandRange function

Posted on 2004-10-29
259 Views
Last Modified: 2013-12-24
I am trying to use the randrange function to randomize some banners I have.  Problem is, it doesn't seem to be going any higher then the number 4

<cfif #story.categoryID# eq 3 OR #story.categoryID# eq 9 OR #story.categoryID# eq 13>
                  <cfparam name="bannerswap" default="#randrange(1, 5)#">
                  <cfif bannerswap is "1">
                        <cfinclude template="random1.cfm">
                  <cfelseif bannerswap is "2">
                        <cfinclude template="random2.cfm">
                  <cfelseif bannerswap is "3">
                        <cfinclude template="random3cfm">
                  <cfelseif bannerswap is "4">
                        <cfinclude template="random4.cfm">
                  <cfelseif bannerswap is "5">
                        <cfinclude template="random5.cfm">
                  </cfif>
            <cfelse>
                  <cfparam name="bannerswap" default="#randrange(1, 7)#">
                  <cfif bannerswap is "1">
                        <cfinclude template="random6.cfm">
                  <cfelseif bannerswap is "2">
                        <cfinclude template="random7.cfm">
                  <cfelseif bannerswap is "3">
                        <cfinclude template="random8.cfm">
                  <cfelseif bannerswap is "4">
                        <cfinclude template="random9.cfm">
                  <cfelseif bannerswap is "5">
                        <cfinclude template="random10.cfm">
                  <cfelseif bannerswap is "6">
                        <cfinclude template="random11.cfm">
                  <cfelseif bannerswap is "7">
                        <cfinclude template="random12.cfm">
                  </cfif>
            </cfif>

Notice how I have 1, 7   or 1, 5.  Well, I cfoutputed   bannerswap and it would never go above the number 4. It would do 1,2,3,4 but never 5,6,7.

Why is that.

Thanks
Bryan
0
Question by:jag5311
    3 Comments
     
    LVL 14

    Accepted Solution

    by:
    Hello jag5311!

    How about changing the following codes :
      <cfparam name="bannerswap" default="#randrange(1, 5)#">
      <cfparam name="bannerswap" default="#randrange(1, 7)#">

    Into these codes :
      <cfset bannerswap = randrange(1, 5)>
      <cfset bannerswap = randrange(1, 7)>

    Hope this helps.  Just try it.


    Goodluck!
    eNTRANCE2002 :-)
    0
     

    Author Comment

    by:jag5311
    genious. Pure genious :)

    I got this off of easycfm.com.

    So far it worked I will let you know and award points.

    Thanks
    0
     

    Author Comment

    by:jag5311
    THANK YOU! Works wonderfully. And funny, but it seems like its faster to in terms of how fast my banners show up or get decided to show.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    5 Experts available now in Live!

    Get 1:1 Help Now