Skip to main content
Known Participant
July 27, 2009
Question

How can I output this dynamically into a table ?

  • July 27, 2009
  • 2 replies
  • 433 views

I have a master table that contains state, then cities for each state.

I want to output each state into its own <td> and then right underneath each state, disply the cites for that state with a checkbox.

I currently do this using separate queries for each state and plug into the <td> :

<td class="TitleText"   valign="top" rowspan="2"><b>New Jersey</b><br>
<cfloop query="qryName>
<cfif qryName.state is "New Jersey">
<cfoutput>
<cfinput type="checkbox" name="city" value="#qryName.city#">#qryName.city#<br>
</cfoutput>
</cfif>
</cfloop>
</td>

So if I have five states, I do this five times, one for each state, to put into the <td>

How can I do this dynamically so that I just have one query and it will know when to switch and put each state and city checkbox into its own cell ?

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    July 27, 2009

    Use cfselect's bind attribute to dynamically populate states and cities using arrays or queries returned from a component. Example 2 of the livedocs on cfselect tells you everything you need to know.

    Inspiring
    July 27, 2009

    The group attribute of cfoutput will work well in this situation.  Details are in the cfml reference manual.  If you don't have one, the internet does.