Al,
Thanks! That gets me off on that part.
Next question:
I need to pull the values out so I have an 'update' form. You'll see
that I'm listing the variables to see if the right values are being
pulled from the db. Only the first one is pulled. Do I have to loop
through the list_org query somehow too? I'm really very confused.
This is what I've got:
<cfif IsDefined('form.action')>
<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>
<!--- 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 org_admin.id AS org_id, * FROM org_admin
</cfquery>
<!--- END GENERIC QUERIES AND VARIABLE SETTING --->
<cfform action="" method="post">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="25%"> </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>
<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.id#
#list_org.org_id#
<cfif
list_org.org_id EQ list.id>
<cfset
checked = "Yes">
<cfelse>
<cfset
checked = "No">
</cfif>
<cfinput
type="checkbox" value="#list.id#" name="org" checked=#checked# />
#org_abbr#<br>
</cfoutput>
</td>
</cfloop>
</tr>
</table>
</td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td width="25%"> </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>
</body>
</html>
> -----Original Message-----
> From: Everett, Al [mailto:[EMAIL PROTECTED]
> Sent: February 26, 2003 9:04 AM
> To: CF-Talk
> Subject: RE: Dynamic Insert
>
>
> Change:
>
> <cfinput type="checkbox" value="1" name="org"
/>#org_abbr#<br> <input type="hidden" > name="org_id" value="#list.id#">
>
> To:
>
> <cfinput type="checkbox" value="#list.id#" name="org_id"
> />#org_abbr#<br>
>
>
> Then on your action page your Form.org_id field will be a
> comma-delimited list of org_id's.
>
>
> Then you can just do this:
>
> <cfif IsDefined('form.action')>
> <cfif IsDefined("Form.org_id") AND ListLen(Form.org_id) GT 0>
> <cfloop list="#Form.org_id#" index="i">
> <cfquery name="addorg" datasource="#DSN#">
> INSERT INTO org_admin
> (
> users_id,
> org_id
> )
> VALUES
> (
> #form.users_id#,
> '#i#'
> )
> </cfquery>
> </cfloop>
> </cfif>
> </cfif>
>
>
>
> > -----Original Message-----
> > From: Jillian Carroll [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, February 26, 2003 9:53 AM
> > To: CF-Talk
> > Subject: Dynamic Insert
> >
> >
> > I've been working on this for a while and I've created a test page
> > before I move this over to my full form.
> >
> > How can I create a loop that will allow my insert to work?
> >
> > This is what I have:
> >
> > <cfif IsDefined('form.action')>
> > <cfquery name="addorg" datasource="#DSN#">
> > INSERT INTO org_admin (users_id, org_id)
> > VALUES (#form.users_id#,'#form.org_id#')
> > </cfquery>
> > </cfif>
> >
> > <!--- GENERIC QUERIES AND VARIABLE SETTING --->
> >
> > <cfquery name="list" datasource="#DSN#">
> > SELECT * FROM organizations ORDER BY org_abbr
> > </cfquery>
> >
> > <!--- END GENERIC QUERIES AND VARIABLE SETTING --->
> >
> > <cfform action="" method="post">
> > <table border="0" cellpadding="0" cellspacing="0">
> > <tr>
> > <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>
> > <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)#">
> > <cfinput type="checkbox" value="1" name="org" />
> > #org_abbr#<br>
> > <input type="hidden" name="org_id"
> value="#list.id#">
> > </cfoutput>
> > </td>
> > </cfloop>
> > </tr>
> > </table>
> > </td>
> > </tr>
> > </table>
> > <br />
> > </td>
> > </tr>
> > <tr>
> > <td width="25%"> </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