Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - CheckBox/Loop Question
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CheckBox/Loop Question

 Post Reply Post Reply
Author
Dubie View Drop Down
Newbie
Newbie
Avatar

Joined: 26 May 2008
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dubie Quote  Post ReplyReply Direct Link To This Post Topic: CheckBox/Loop Question
    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
Back to Top
jamie.townsend View Drop Down
Groupie
Groupie


Joined: 07 December 2007
Location: England
Status: Offline
Points: 114
Post Options Post Options   Thanks (0) Thanks(0)   Quote jamie.townsend Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.