Print Page | Close Window

CheckBox/Loop Question

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=25761
Printed Date: 29 March 2026 at 3:11am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: CheckBox/Loop Question
Posted By: Dubie
Subject: CheckBox/Loop Question
Date Posted: 26 May 2008 at 6:46am

Sup all,

 I have a asp page that shows a list of a players game items.
On this page I have a delete button for each item he has.
I would like to have a checkbox next to each item instead.
Then have one button at the bottom that would delete all the items with a check.
Server software I am useing I have to delete one item at a time.
I need two things:
1.) I need to be able to tell which checkbox is selected.
2.) Then loop through each item till its done.
 
Here is my delete function I use know for each items delete button:
 

if request.form("act") = "delete" then
 itemId = request.Form("itemId") 
 itemAmount = request.Form("itemcount")  
 
 tmp = DelItem(cid, stored, itemId, itemcount) 
 if not tmp then
  if request.form("location") = "user" then
   table = "player_items"
  else
   table = "player_warehouse"
  end if
 
  strsql = "DELETE FROM " & table & " WHERE item_id=" & itemId
  gamedb1_conn.execute(strsql) 
 end if
 
 response.Redirect("playeyitems.asp")
end if
 
I have not worked with having checkboxes and loops. Confused
Any help would be appreciated.
 
Thanks,
Dubie



Replies:
Posted By: jamie.townsend
Date Posted: 27 May 2008 at 10:28am
ok, firstly you need to give the checkbox a unique name.
So for example, inside the loop you would have <input type="check" name="delete-(ID NUMBER)">

Then, when you click the delete all button that fires a "select * from sametable" this will then let you be able to create the variable DeleteItem = request.form("delete-"&rs("id"))

Then all you do is check the value equals "on" and if it does you know to delete that ID.

Hope this helps, let me know if you need a more help.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net