A better way to handle variables when nesting CFLOOP

Dev

A better way to handle variables when nesting CFLOOP

by Kyle Godard
//

If you try to reference a value from the outer query within a nested CFLOOP you normally get only the first value from the outer query rather than the value of the current row. In the past a common solution has been to store a temporary value before the nested loop.

 

     
     
          #qCities.City#, #tempState#

    

 

But this can become cumbersome when dealing with several values and a layer of complexity when reading through the code. A better way to do this is to access the outer query directly using the current row.

 

     
          #qCities.City#, #qStates["State"][qStates.CurrentRow]#
     

 

More About the Author

Kyle Godard

Software Engineer
Read Only Radio Button Consider the following situation: you would like a set of radio buttons on a form that will have a value preselected. You don’t want to ...
A better way to handle variables when nesting CFLOOP If you try to reference a value from the outer query within a nested CFLOOP you normally get only the first value from the outer query ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!