Wrox Programmer Forums
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 28th, 2004, 10:48 AM
Friend of Wrox
Join Date: Nov 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky
Default Edit value from Table


I have got an asp page that query a SQL DB and build a Table from the returned data. I need to add a checkbox next to each row and allow the user to select a value and Edit or delete.

My question is. How do I know which checkbox is ticked and how do I get the corresponding value?

Old June 28th, 2004, 10:11 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

Hi Marnus,

This was discussed in this/other thread many times, but with the new changed UI, I am not able to find that easily out for you. Any search now hits the entire forum and I got to scroll through 50 odd pages to find that out. Maybe, got to get used to this new UI. I am unable to locate the old Search facility(if at all it is there) that lets one to search based on forum/thread and was a good and easy way to find things. I don't see that here now. Maybe if someone finds let me know. Not only that, I find it odd/difficult to get adapted with content in BLACK letters. The old UI was so good. Don't know why a sudden revamp of the site.

So let me explain you on how to go with the checkbox thing.

You should be looping through the recordset for displaying the data in a table. Within that loop, you got to use checkbox that has the same name for every instance.

<td><input type="checkbox" name="chkDelete" value='<%=rs("IDFIELD")%>'></td>
<td>COL1 - Your record displaying code...</td>
<td>Col2 - Your record displaying code...</td>
Suppose, you have listed records from 1-10, and check box is ticked for 1, 4, 5, 8. When you request the value of that checkbox after form submit.

Response.write Request.Form("chkDelete")
would result in 1,4,5,8 all comma separated.

You can split that into an array or process that as such.
For delete, it is sufficient that it is comma seperated, so that you can use the query as
strsql="delete from mytable where idfield in (" & Request.Form("chkDelete") & ")"
Which would result in query as
delete from mytable where idfield in (1,4,5,8)
I won't suggest this method for update, for which you got to provide all the columns as editable and on checked status of the CHECKBOX, you got to capture the data for relevant rows and update them in a batch, which would be a little more complex. If you are comfortable with it, you can go ahead with this, but you got to use SPLIT function to split the 1,4,5,8 into an array and loop through each value to construct the UPDATE statement and proceed further.

Hope that helps.

- Vijay G
Strive for Perfection

Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit Access Table in Excel (2003) kewldude_3001 Access 0 April 10th, 2008 02:26 PM
Edit Table through a Form Coby Access VBA 3 August 17th, 2007 07:10 AM
CH 6 (edit the table) mekanaren BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 October 27th, 2006 09:40 AM
pg190 edit/delete code for 'people' table ?? jeronimo BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 June 28th, 2004 01:29 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.