Search code examples
coldfusioncoldfusion-11

How to increase variable number using loop?


In Coldfusion, how do I increase a variable number by 1 for 5 loops?

I tried the following:

<cfset num = 19001>

<cfoutput>

<cfloop index="i" from="#num#" to="5">
    #num#
</cfloop>

</cfoutput>

But this is not working.


Solution

  • You can do it like this:

    <cfset num = 19001>
    
    <cfoutput>
      <cfloop index="i" from="#num#" to="#num+5#">
        #i#
      </cfloop>
    </cfoutput>