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.
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.
You can do it like this:
<cfset num = 19001>
<cfoutput>
<cfloop index="i" from="#num#" to="#num+5#">
#i#
</cfloop>
</cfoutput>
You could simply loop from 1 to 5 and add 1 to your base number each time. Then your starting number can be anything and you don't need to calculate your end value ahead of time.
<cfset num = 19001>
<cfoutput>
<cfloop index="i" from="1" to="5">
<cfset num = num + 1>
#num#
</cfloop>
</cfoutput>