How about this?

<cfset listChecked = valueList(query.roleID)>
<tr>
<cfloop index="counter" from="1" to="5">
<td><input type="checkbox" name="RoleID" value="#counter#" <cfif
listContains(listChecked,counter)>CHECKED</cfif>></td>
</cfloop>
</tr>

-----Original Message-----
From: sebastian palmigiani [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 20, 2000 12:42 PM
To: [EMAIL PROTECTED]
Subject: Query to Check Boxes [CF-Talk]



I have 5 check boxes displayed in a form. I want to show a checked status on
the check boxes based on the query. The query output varies from 0 to 5
records.

Here is what I have now. There has to be a more efficient way.

<cfparam name="Role1" default=" ">
<cfparam name="Role2" default=" ">
<cfparam name="Role3" default=" ">
<cfparam name="Role4" default=" ">
<cfparam name="Role5" default=" ">

<cfoutput query="ShowPriviliges">
<cfif RoleID EQ 1><cfset checked1 = "checked"></cfif>
<cfif RoleID EQ 2><cfset checked2 = "checked"></cfif>
<cfif RoleID EQ 3><cfset checked3 = "checked"></cfif>
<cfif RoleID EQ 4><cfset checked4 = "checked"></cfif>
<cfif RoleID EQ 5><cfset checked5 = "checked"></cfif>
</cfoutput>

<cfoutput>
<tr>
<td><input type="checkbox" name="RoleID" value="1" #checked1#></td>
<td><input type="checkbox" name="RoleID" value="2" #checked2# ></td>
<td><input type="checkbox" name="RoleID" value="3" #checked3#></td>
<td><input type="checkbox" name="RoleID" value="4" #checked4#></td>
<td><input type="checkbox" name="RoleID" value="5" #checked5#></td>
</tr> 
</cfoutput>

Sebastian

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to