recordset from multiple checkbox values

Please support our ASP advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Mar 2005
Posts: 131
Reputation: william_stam is an unknown quantity at this point 
Solved Threads: 2
william_stam's Avatar
william_stam william_stam is offline Offline
Junior Poster

recordset from multiple checkbox values

 
0
  #1
Mar 10th, 2005
I have a page that displays the records from the database (repeated down) if the user selects (checkbox) a few records and clicks submit it passes the value (dbase record ID) to another page that retrieves the value and builds another recordset with just the records selected from the first page.

The webmail pages make use of this (ie: select a few e-mails and click "trash" and those e-mails get deleted)
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: recordset from multiple checkbox values

 
0
  #2
Mar 21st, 2005
Give your checkboxes the same name.
<input type="checkbox" name="mycheckbox" value="1">
<input type="checkbox" name="mycheckbox" value="2">
.
.
.
n

Then when the form is posted you have an array which you can iterate or pass to a stored procedure or whatever your prefered method is.

  1. sql="update table set column=value where id in ("
  2.  
  3. for i = 0 to Request.Form("mycheckbox").length - 1
  4. if i=0 then
  5. sql=sql & Request.Form("mycheckbox").item(i)
  6. else
  7. sql=sql & "," & Request.Form("mycheckbox").item(i)
  8. end if
  9. next
  10.  
  11. sql = sql & ")"
  12.  
  13. con.execute(sql)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC