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=3input type=checkbox name=submitButtonName value=Delete/TD TD valign=top width=5% class=filetrackernbsp;#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=subscribeforumid=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
RE: Deleting entries from database via checkbox
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=3input type=checkbox name=submitButtonName value=Delete/TD TD valign=top width=5% class=filetrackernbsp;#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=subscribeforumid=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
RE: Deleting entries from database via checkbox
Set the value of your checkbox to the primary key of the record you want to delete. Then, on your action page, you will have a comma-delimited list of IDs to delete. cfquery name=del datasource=#ds# DELETE FROM myTable WHERE PRIMARY_KEY_ID IN (#Form.Delete#) /cfquery -Original Message- From: FlashGuy [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 1:06 PM 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=3input type=checkbox name=submitButtonName value=Delete/TD TD valign=top width=5% class=filetrackernbsp;#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=subscribeforumid=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