Closed Thread Icon

Topic awaiting preservation: Delete all choice from checkbox problem (ASP) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12939" title="Pages that link to Topic awaiting preservation: Delete all choice from checkbox problem (ASP)" rel="nofollow" >Topic awaiting preservation: Delete all choice from checkbox problem (ASP)\

 
Author Thread
Hiroki
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:

1.show 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:

code:
Dim sql

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

'response.write(s)
'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).
'Hmm.....why????

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

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



And in html form, inside of table:

code:
<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:

Response.Write(Request.Form("delete)),

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

@_@ Help, please.



Hiroki Kozai

Rhino
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