You'll want to rename your checkbox to 'itemID' or something like that, and
then set the VALUE attribute to the itemID of the record you're currently
processing:

<cfoutput ... >
   ...
   <input type="checkbox" name="itemID" value="#itemID#" />
   ...
</cfoutput>

When the form is submitted, the FORM variable will not exist if nothing was
checked, or it'll contain a comma delimited list of values for the boxes
were checked.  Then you just need to do this:

<cfquery ...>
   DELETE FROM my_table
   WHERE itemID IN (#form.itemID#)
</cfquery>

Of course, you'll want to validate the input first so people don't construct
their own list of IDs that screw other people up, but that's the basic idea.

barneyb

> -----Original Message-----
> From: FlashGuy [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 05, 2003 10:06 AM
> To: CF-Talk
> Subject: Deleting entries from database via checkbox
>
>
> HI,
>
> I'm displaying entries from my database in my template. I have
> <input checkboxes displayed on every line. I would like to be
> able to check on a box or multiple boxes and
> when a click on my "Delete" button on my template those entries
> are deleted from my database.
>
> Here is the code that displays the entries from my database.
>
> <CFOUTPUT QUERY="GetEnv">
>       <TR bgcolor="#bgColor(currentRow MOD 2,"silver","white")#">
>       <TD valign="top" width="3"><input type="checkbox"
> name="submitButtonName" value="Delete"></TD>
>       <TD valign="top" width="5%"
> class="filetracker">&nbsp;#GetEnv.Filename#</TD>
>       <TD align="center" valign="top" width="5%">#GetEnv.Command#</TD>
>       <TD align="center" valign="top" width="15%">#GetEnv.CreatedOn#</TD>
>       <TD align="center" valign="top" width="15%">#GetEnv.LastAcc#</TD>
>       <TD align="center" valign="top" width="15%">#GetEnv.LastMod#</TD>
>       <TD align="center" valign="top" width="5%">#GetEnv.FileSize#</TD>
>       <TD valign="top" width="15%">#GetEnv.Directory#</TD>
>       <TD align="center" valign="top" width="5%">#GetEnv.Username#</TD>
>       <TD valign="top" width="20%">#GetEnv.FileDescription#</TD>
> </TR>
> </CFOUTPUT>
>
>
>
>
>
>
>
> ---------------------------------------------------
> Colonel Nathan R. Jessop
> Commanding Officer
> Marine Ground Forces
> Guatanamo Bay, Cuba
> ---------------------------------------------------
>
>
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

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

Reply via email to