Closed Thread Icon

Topic awaiting preservation: Delete all choice from checkbox problem (ASP) (Page 1 of 1) Pages that link to <a href="" title="Pages that link to Topic awaiting preservation: Delete all choice from checkbox problem (ASP) (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Delete all choice from checkbox problem (ASP) <span class="small">(Page 1 of 1)</span>\

Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 10-17-2003 04:02

Hi, guys. How are you?
It is pretty warm here in New zealand. Spring here!

Anyway, can I ask you this thing?
What I am trying to do is: the list of wine ( access database) using ASP and ADO.
2.Each item has checkbox to be deleted.
3.All the checked list has to be deleted all at once when user hit delete button.

I wrote a code do delete like this:

Dim sql

If Request.Form("action") = "Delete" Then
Dim s
s = Request.Form("delete")

's is ID which you choose to delete. 1, 23, 12 something like that.
'so that you have to replace each space or , to "" (means nothing).

s = Replace(s, " ", "")
s = Replace(s, ",", "")

If IsNumeric(s) Then
sql = "DELETE FROM tblWine WHERE[ID] IN("& Request.Form("delete") & ") "
On Error Resume Next
conn.Execute sql
If Err.Number <> 0 Then
Response.Write "error"
End IF
End IF

And in html form, inside of table:

<td><input type="checkbox" name="delete" value="<%=x.value%>"></td>

Basiclly it works fine. But I don't understand how those replace (s, " ", "") works.
Without that, I cannot delete multiple items but single.

When I do like:


it shows 1, 3, 4, 12 or whichever ID number where I checked.

@_@ Help, please.

Hiroki Kozai

Bipolar (III) Inmate

From: New Jersey, USA
Insane since: Jul 2003

posted posted 10-17-2003 10:06

It looks like if you select multiple choices you said the value of Request.Form("delete") comes back as a string separated by commas. Then to run the delete statement you check to see if the value of Request.Form("delete") isNumeric. It doesn't look like it would ever be numeric when you select multiple items.

Why don't you check to see if the value isNull before running the delete since it should always be numeric since you are using ID's. That way you would never have to replace.

« BackwardsOnwards »

Show Forum Drop Down Menu