I have a form that has a number of checkboxes that are generated
dynamically.  I have two problems: how can I 'recall' the values of
these checkboxes so that I can check/uncheck them later (the idea of
this form is students being assigned to organizations for study, so they
might belong to one or more and they may change), but also how do I
write the update query in a 'dynamic looping' way given the variable
number of checkboxes?
 
Problems:
 
1.    When I display the checkboxes, not all of the checkboxes that
should be checked, are.
2.    How can I take this information and create an update query?
 
My problem is that I'm not really sure how this should be working...
what would be the best approach.  I'm happy to go and learn how to do
this... but I have no idea what to learn about.
 
Any help would be greatly appreciated.
 
--
 
This is what I have so far:
 
 <cfif IsDefined('form.action')>
  <cfif form.action eq 'add'>
   <cfif IsDefined("form.org") AND ListLen(form.org) GT 0>
    <cfloop list="#form.org#" index="i">
     <cfquery name="addorg" datasource="#DSN#">
     INSERT INTO org_admin 
     (
      users_id,
      org_id
     )
     VALUES
     (
      #form.users_id#,
      '#i#'
     )
     </cfquery>
    </cfloop>
   </cfif>
  </cfif>
  <cfif form.action eq 'update'>
  </cfif>
 </cfif>
 
 <!--- GENERIC QUERIES AND VARIABLE SETTING --->
 
 <cfquery name="list" datasource="#DSN#">
 SELECT  * 
 FROM  organizations 
 ORDER BY org_abbr
 </cfquery>
 
 <cfquery name="list_org" datasource="#DSN#">
 SELECT  * 
 FROM  org_admin
 WHERE  users_id = #url.id#
 </cfquery>
 
 <!--- END GENERIC QUERIES AND VARIABLE SETTING --->
 
 <cfform action="" method="post">
 <table border="0" cellpadding="0" cellspacing="0">
 <tr>
    <td width="25%">&nbsp;</td>
    <td colspan="3">
    <table cellpadding="2" cellspacing="0" width="100%">
    <tr>
     <td>Please select the Lung Associations that this user is
responsible for:</td>
    </tr>
    <tr>
     <td>
     <cfoutput>#list_org.org_id#</cfoutput>
 
     <CF_Columns Cols="3" Records="#list.RecordCount#">
   
     <table border="0" cellpadding="2" cellspacing="0" width="100%">
     <tr>
     <!--- Loop through the number of columns desired. --->
     <cfloop index="LoopCount" from="1" to="3">
      <!--- Access the start and end variables created by the custom
tag. --->
      <cfset #start# = ("start" & #LoopCount#)>
      <cfset #end# = ("end" & #LoopCount#)>
      <td valign="top">
      <cfoutput query="list" startrow="#Evaluate(start)#"
maxrows="#Evaluate(end)#">
       #list_org.id#
       <cfinput type="checkbox" value="#list.id#" name="org" />
#org_abbr#<br>
      </cfoutput>
      </td>
     </cfloop>
     </tr>
     </table>
 
     </td>
    </tr>
    </table>
    <br />
    </td>
 </tr>
 <tr>
  <td width="25%">&nbsp;</td>
  <td colspan="3">
  <cfoutput><input type="hidden" name="users_id"
value="#url.id#"></cfoutput>
  <input type="hidden" name="action" value="add">
  <input type="submit" name="Submit">
  </td>
 </tr>
 </table>
 </cfform>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to