>Michael,
>
>I may not fully understand your situation, but this works for me. I
>manually created 2 queries to simulate your data: one with the rids
>and taids that the user selected; another simulating the target
>audience reference table (only did 5 of the 9).
>
>The qAudienceValues query has 3 of the 5 options. I convert those to a
>list with ValueList(). Then just loop through the TargetAudience
>query, outputting as needed.
>
><!--- Query of user selected options --->
><cfset qAudienceValues = QueryNew('rid,taid')>
><cfset QueryAddRow(qAudienceValues,3)>
><cfset QuerySetCell(qAudienceValues,'rid',1,1)>
><cfset QuerySetCell(qAudienceValues,'taid',1,1)>
><cfset QuerySetCell(qAudienceValues,'rid',2,2)>
><cfset QuerySetCell(qAudienceValues,'taid',3,2)>
><cfset QuerySetCell(qAudienceValues,'rid',3,3)>
><cfset QuerySetCell(qAudienceValues,'taid',5,3)>
>
><!--- Query of Target Audiences --->
><cfset qTargetAudience = QueryNew('taid,targetAudience')>
><cfset QueryAddRow(qTargetAudience,5)>
><cfset tmpList = "General
>Public(Adults),Children ⁄ Youth,Seniors,Elected
>Officials ⁄ Policy Makers,Extension
>Educators ⁄ Teachers">
><cfloop list="#tmpList#" index="i">
> <cfset
> QuerySetCell(qTargetAudience,'taid',ListFind(tmpList,i),ListFind(tmpList,i))>
> <cfset
> QuerySetCell(qTargetAudience,'targetAudience',i,ListFind(tmpList,i))>
></cfloop>
>
><cfoutput>
><cfset AudienceTAIDs = ValueList(qAudienceValues.taid) />
><cfloop query="qTargetAudience">
><input type="checkbox" <cfif ListFind(AudienceTAIDs,taid)>checked</cfif>>
>#targetAudience#<br />
></cfloop>
></cfoutput>
>
>
>--
>Matt Williams
>"It's the question that drives us."
Matt,
Thanks for your help. Giving a clear picture through forumns is tough sometimes
without giving people access to a particular site, however, you were pretty
close to what we were trying to achieve. Based on your feedback, we were able
to fix our previous attempts at <cfset>, <cfif>, ValueList(), and ListFind().
You gave us a good footing to use.
Here's what we did:
<!--- Pulls data from the audience values table --->
<cfquery name="qUpdateAudienceValues" datasource="#dsn#">
SELECT *
FROM audienceValues, targetAudience
WHERE rid = '#url.did#'
AND audienceValues.taid = targetAudience.taid
</cfquery>
<!--- Sets Value List to Values Returned by Query --->
<cfset audienceTAIDs = ValueList(qUpdateAudienceValues.taid)>
....and the sample code with <cfif> and ListFind()
<td>
<label><input type="checkbox" id="generalPub"
name="targetAudience" value="1" <cfif ListFind(audienceTAIDs,1)
>checked="checked"</cfif> />General Public(Adults)</label><br />
<label><input type="checkbox" id="children"
name="targetAudience" value="2" <cfif ListFind(audienceTAIDs,2)
>checked="checked"</cfif> />Children ⁄ Youth</label><br />
<label><input type="checkbox" id="seniors"
name="targetAudience" value="3" <cfif ListFind(audienceTAIDs,3)
>checked="checked"</cfif> />Seniors</label><br />
<label><input type="checkbox" id="officials"
name="targetAudience" value="4" <cfif ListFind(audienceTAIDs,4)
>checked="checked"</cfif> />Elected Officials ⁄ Policy
Makers</label><br />
<label><input type="checkbox" id="extension"
name="targetAudience" value="5" <cfif ListFind(audienceTAIDs,5)
>checked="checked"</cfif> />Extension
Educators ⁄ Teachers</label><br />
</td>
Is there a way to make a dynamic list of checkboxes, as you have provided in
your example, display into 2 columns on the page? Doing a dynamic list is much
cleaner, but I need to display 2 columns on the Web page.
Thanks again!
Michael
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four
times a year.
http://www.fusionauthority.com/quarterly
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:253296
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4