railo - ColdFusion - Collection loop in cfscript -
i have tag based syntax works in railo.
<cfloop collection="#myarray#" item="j" index="i"></cfloop>
the above allows me access index 'i' , item itself, 'j'.
i want same in cfscript, used:
for ( in myarray) {}
however, 'i' gives me item...how can access index value?
as work-around, have had manually count index so:
j = 1; ( in myarray) { j++; }
but feels dirty. in syntax of cfscript allow true alternative cfloop's collection?
i have tried google searching of never decent result. there way rewrite in loop allow me access index too?
thanks, mikey.
it's not possible in coldfusion, i'm afraid, other work-around using, or using indexed loop.
however in railo, there (rather awful tag/script hybrid syntax):
<cfscript> loop array=[5,4,3,2,1] index="i" item="v" { writeoutput("[#i#][#v#]<br>"); } </cfscript>
so it's <cfloop>
without angle brackets.
Comments
Post a Comment