Good afternoon,

I am trying to have multiple checkboxes be checked based on data in a table for 
an edit page and can only get the first record to be checked. I've tried 
<cfloop> and ValueList() several ways and get the same results. Obviously, I'm 
missing something and hope that someone can provide me with some direction.

I have a table that is used for reference (targetAudience) that contains a 
number and name for 9 items. I match it to user submitted results in another 
table (audienceValues) by using the primary key "rid" - which is short for 
resource ID. 

Here's the query and loop:

<!--- 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>

<!--- Loop through and set the local variables for the Traget Audience --->

<cfloop query="qUpdateAudienceValues">
 <cfif #qUpdateAudienceValues.taid# EQ 1>
  <cfset targetAudience1 = 'Yes'>
   <cfelse>
    <cfset targetAudience1 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 2>
  <cfset targetAudience2 = 'Yes'>
   <cfelse>
    <cfset targetAudience2 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 3>
  <cfset targetAudience3 = 'Yes'>
   <cfelse>
    <cfset targetAudience3 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 4>
  <cfset targetAudience4 = 'Yes'>
   <cfelse>
    <cfset targetAudience4 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 5>
  <cfset targetAudience5 = 'Yes'>
   <cfelse>
    <cfset targetAudience5 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 6>
  <cfset targetAudience6 = 'Yes'>
   <cfelse>
    <cfset targetAudience6 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 7>
  <cfset targetAudience7 = 'Yes'>
   <cfelse>
    <cfset targetAudience7 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 8>
  <cfset targetAudience8 = 'Yes'>
   <cfelse>
    <cfset targetAudience8 = 'No'>
 </cfif>
 
 <cfif #qUpdateAudienceValues.taid# EQ 9>
  <cfset targetAudience9 = 'Yes'>
   <cfelse>
    <cfset targetAudience9 = 'No'>
 </cfif>
</cfloop>


Here's the checkbox group:

<tr>
                  <td>
                  <label><input type="checkbox" id="generalPub" 
name="targetAudience" value="1" <cfif targetAudience1 EQ 'Yes' 
>checked="checked"</cfif> />General Public(Adults)</label><br />
                  <label><input type="checkbox" id="children" 
name="targetAudience" value="2" <cfif targetAudience2 EQ 'Yes' 
>checked="checked"</cfif> />Children&nbsp;&frasl;&nbsp;Youth</label><br />
                  <label><input type="checkbox" id="seniors" 
name="targetAudience" value="3" <cfif targetAudience3 EQ 'Yes' 
>checked="checked"</cfif> />Seniors</label><br />
                  <label><input type="checkbox" id="officials" 
name="targetAudience" value="4" <cfif targetAudience4 EQ 'Yes' 
>checked="checked"</cfif> />Elected Officials&nbsp;&frasl;&nbsp;Policy 
Makers</label><br />
                  <label><input type="checkbox" id="extension" 
name="targetAudience" value="5" <cfif targetAudience5 EQ 'Yes' 
>checked="checked"</cfif> />Extension 
Educators&nbsp;&frasl;&nbsp;Teachers</label><br />
                 </td>
                 <td>
                  <label><input type="checkbox" id="disaster" 
name="targetAudience" value="6" <cfif targetAudience6 EQ 'Yes' 
>checked="checked"</cfif> />Disaster Professionals</label><br />
                  <label><input type="checkbox" id="farmers" 
name="targetAudience" value="7" <cfif targetAudience7 EQ 'Yes' 
>checked="checked"</cfif> 
/>Farmers&nbsp;&frasl;&nbsp;Ranchers&nbsp;&frasl;&nbsp;Producers</label><br />
                  <label><input type="checkbox" id="business" 
name="targetAudience" value="8" <cfif targetAudience8 EQ 'Yes' 
>checked="checked"</cfif> />Business 
Owners&nbsp;&frasl;&nbsp;Operators</label><br />
                  <label><input type="checkbox" id="scientists" 
name="targetAudience" value="9" <cfif targetAudience9 EQ 'Yes' 
>checked="checked"</cfif> />Scientists&nbsp;&frasl;&nbsp;Engineers</label><br />
                 </td> 
                </tr>

Any help or information is greatly appreciated.

Thanks.

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:253154
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to