Try changing your CategoryID (for the loop index)
to CATID and try that. Example:
<cfloop query="getAllCats">
<cfoutput>#Category# </cfoutput>
<CFSET CURRENTCATID = getAllCats.CategoryID>
<cfloop index="CATID" list="getCats">
<input type="checkbox" name="CategoryID" value=""
<CFIF #CURRENTCATID# IS #getCats.CategoryID#>checked</CFIF>
</cfloop>
Your trying to set the CFLOOP INDEX Variable to
an existing Query variable thus confusing the
CFOUTPUT
-----Original Message-----
From: Seamus Campbell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 11, 2001 9:59 AM
To: CF-Talk
Subject: RE: looping (I think) problems
Many thanks for the quick reply -
but that code still only picks up the first CategoryID ie if a Client has 2
or more Categories it just loops thru to the first one but doesn't go any
further
Any other clues ??
Ta
Seamus
At 11:12 pm 11/07/01 , you wrote:
>Query values can be lost when attempting to loop inside another.
>
>Try storing the current query value of the parent loop into a variable
>first. Then use this inside your nested cfloop.
>
>Try the following (See CURRENTCATID):
>
><cfquery name="getAllCats" datasource="#application.DSN#">
> SELECT CategoryID, Category
> FROM tblClientCategoryTypes
></cfquery>
>
><cfquery name="getCats" datasource="#application.DSN#">
> SELECT ClientID, CategoryID
> FROM tblClientCategory
> WHERE ClientID=#FORM.ClientID#
></cfquery>
>
><form action="action.cfm" method="post">
><cfloop query="getAllCats">
> <cfoutput>#Category# </cfoutput>
> <CFSET CURRENTCATID = getAllCats.CategoryID>
>
> <cfloop index="CategoryID" list="getCats">
> <input type="checkbox" name="CategoryID" value=""
> <CFIF #CURRENTCATID# IS
>#getCats.CategoryID#>checked</CFIF>
> </cfloop>
> <BR>
></cfloop>
></form>
>
>-----Original Message-----
>From: Seamus Campbell [mailto:[EMAIL PROTECTED]]
>Sent: 11 July 2001 12:14
>To: CF-Talk
>Subject: looping (I think) problems
>
>
>Hi
>
>I have 3 tables: (Access database)
>
>tblClient has fields:
>ClientID
>ClientEmail
>ClientName
>.....
>
>tblClientCategory has fields:
>ClientID
>CategoryID
>
>tblClientCategoryTypes has fields:
>CategoryID
>Category
>
>So clientID can have one or more Categories.
>
>I am trying to build an edit form so that on editing a single ClientID you
>see all categories (with checkboxes) in tblClientCategoryTypes but have
>checked only those where there is a corresponding CategoryID in
>tblClientCategory .
>
>I can only get my form to check the first corresponding record. This is my
>code (I'm sure that I need to cfloop in the form but am having huge
>problems.
>
><cfquery name="getAllCats" datasource="#application.DSN#">
>SELECT CategoryID, Category
>FROM tblClientCategoryTypes
></cfquery>
>
><cfquery name="getCats" datasource="#application.DSN#">
>SELECT ClientID, CategoryID
>FROM tblClientCategory
>WHERE ClientID=#FORM.ClientID#
></cfquery>
>
><form action="action.cfm" method="post">
><cfloop query="getAllCats">
><cfoutput>#Category# </cfoutput><cfloop index="CategoryID" list="getCats">
><input type="checkbox" name="CategoryID" value="" <CFIF
>#getAllCats.CategoryID# IS
#getCats.CategoryID#>checked</CFIF></cfloop>><BR>
></cfloop>
></form>
>
>Any help gratefully received. I can understand conceptually how looping
>works but have have huge problems implementing anything that works.
>MTIA
>Seamus
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists