Check box in search results list to delete multipl

Results 1 to 2 of 2

Thread: Check box in search results list to delete multipl

  1. #1
    Join Date
    Dec 1969

    Default Check box in search results list to delete multipl

    I&#039;m trying to set up a deletion routine where a check box next to a database search results list item is selected to choose records for removal - when the form is submitted it posts to a page which will contain the delete sequence to remove the database record and the uploaded file that the database is referencing from the server.<BR><BR>The problem I have is how to refer to the form values in the posted-to page as I have used the filename from the database record to name the check box for each item:<BR> <BR>(i.e. Response.write "&#060;input type=checkbox name="& rs("uFilename") &" value=selecttoDelete&#062;")<BR><BR>their values depend on the page user (I have tried using the same sql string and while loop that produced the values in the form page, in the posted-to page to dynamically reproduce the Request.Form() field). Below is a sample of code I tried that doesn&#039;t work. Any suggestions or should I completely rethink my approach to the deleting mechanism?<BR><BR>&#039;SqlDel = "Delete * From Uploads WHERE "<BR>Sql = "Select * From Uploads WHERE UserID = &#039;"& Session("UserID") &"&#039; "<BR>Set rs = Conntemp.Execute(Sql)<BR><BR>If rs.EOF &#060;&#062; "True" Then<BR>While rs.EOF &#060;&#062; "True"<BR>cbName = rs("uFilename")<BR>If Request.Form(""& cbName &"") = "selecttoDelete" Then<BR>&#039;SqlDel = SqlDel & "uFilename = &#039;"& Request.Form("cbName") &"&#039;, "<BR>Response.write "DEBUG: " & Request.Form(""& cbName &"")<BR>End If<BR>rs.Movenext<BR>Wend<BR>End If<BR><BR>rs.close<BR>Set rs = Nothing<BR>Conntemp.Close<BR>Set Conntemp = Nothing<BR><BR><BR>The only other thing I can think of to delete multiple records at once is to have the whole thing in one page and use a Select Case routine e.g. Case Delete

  2. #2
    Join Date
    Dec 1969

    Default RE: Check box in search results list to delete mul

    The delete you are doing has *nothing* to do with any of the checkboxes...<BR><BR>If you have an Id in the table...Name all your checkboxes the same...When you loop through your recordset, assign the value of each checkbox to the table id...<BR><BR>Do While Not rs.Eof<BR><BR>&#060;input type="checkbox" name="DeleteItem" value="&#060;%=rs("id")%&#062;"<BR><BR>rs.MoveNext <BR><BR>Loop<BR><BR>Then when you post, the form element will return a comma delimited string of the checked items and you can do this...<BR><BR>StrSql = "DELETE FROM SomeTable WHERE Id IN (" & Trim(Request.Form("DeleteItem")) & ")"<BR><BR>This is presuming the id is numeric...If it&#039;s character..Then just do this...<BR><BR>DeleteItem = Request.Form("DeleteItem")<BR><BR>DeleteSetup = Replace(DeleteItem, " , " , " &#039;,&#039; ")<BR><BR>You&#039;ll have to look at the Request.Form("deleteItem") string...It is either in 1,2,3 form or 1, 2, 3 form...You&#039;ll have to adjust the replace accordingly...<BR><BR>StrSql = "DELETE FROM TableName WHERE Id IN (&#039;" & DeleteSetup & "&#039;)"<BR><BR>Then cn.Execute(StrSql)<BR><BR>Hope this helps...<BR><BR>KLC<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts