|
| |
|
|
Topic Starter
Posts: 49 From: Canada, eh? Status: offline
|
Updating using checkboxes - 2/22/2002 11:12:40
Hey all. I've got a client with a site that allows users to post surplus items for a certain amount of time. I need to give the members the option of renewing any number of their itmes. So I want to have a database query listing all postings that are expiring say within 1 week. Each of these have a checkbox beside them. This I can do no problem, its just the next page that I'm worried about. How can I do the update? With an array? Do I make an array of the checkboxes? What would be the syntax? Any help greatly appreciated.
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: Updating using checkboxes - 2/22/2002 14:36:00
This is how I did something similar. I had a list of Photo Requests that the status needed to be updated from "Order" to "Hold" (change the value of a field from "O" to "H"). The DRW to display the ordered photos looked like: <!--#include file="../_fpclass/fpdblib.inc"--> <% fp_sQry="SELECT * FROM ""Pending Requests"" ORDER BY ""Client Last"" ASC" fp_sDefault="" fp_sNoRecords="<tr><td colspan=5 align=left width=""100%"">No requests not printed.</td></tr>" fp_sDataConn="photorequest" fp_iMaxRecords=0 fp_iCommandType=1 fp_iPageSize=0 fp_fTableFormat=True fp_fMenuFormat=False fp_sMenuChoice="" fp_sMenuValue="" fp_iDisplayCols=5 fp_fCustomQuery=False BOTID=0 fp_iRegion=BOTID %> <!--#include file="../_fpclass/fpdbrgn1.inc"--> <tr> <td bgcolor="#FFFFFF" width="5%"><font face="Arial" size="1"><input type="checkbox" name="CA<%=FP_iCount%>" value="ON"></font></td> <td bgcolor="#FFFFFF" width="25%"><font face="Arial" size="1"><%=FP_FieldVal(fp_rs,"Client Last")%></font></td> <td bgcolor="#FFFFFF" width="20%"><font face="Arial" size="1"><%=FP_FieldVal(fp_rs,"Client First")%></font></td> <td bgcolor="#FFFFFF" width="30%"><font face="Arial" size="1"><%=FP_FieldVal(fp_rs,"Client City")%></font></td> <td bgcolor="#FFFFFF" width="15%"><font face="Arial" size="1"><%=FP_FieldVal(fp_rs,"Date Ordered")%></font></td> <td bgcolor="#FFFFFF" width="5%"><font face="Arial" size="1"><%=FP_FieldVal(fp_rs,"RecordID")%></font></td> </tr> <INPUT TYPE=HIDDEN NAME=RecID VALUE="<%=FP_FieldVal(fp_rs,"RecordID")%>"> <!--#include file="../_fpclass/fpdbrgn2.inc"--> Notice I used recursive numbering of my checkboxes and that Spooky diet is a must. Each record had a checkbox. This was all contained inside a form that I posted to the next page. The action code on the next page looks like: <% 'set up and grab data from submission DIM tempID, arrTemp, arrActionTemp, strTemp, actionTemp strTemp = Request.Form("RecID") 'clean up record IDs and actions and put in array arrTemp = split(strTemp, ",") DIM iLoop FOR iLoop = LBound(arrTemp) TO UBound(arrTemp) arrTemp(iLoop) = Trim(arrTemp(iLoop)) NEXT 'start loop for updating records FOR x = LBound(arrTemp) TO UBound(arrTemp) tempID = arrTemp(x) 'Test for checkbox IF Request.Form("CB" & x) = "ON" THEN accessdb=server.mappath("fpdb\request.mdb") strconn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" strconn=strconn & accessDB & ";" 'strconn=strconn & "USER ID=;PASSWORD=;" mySQL = "UPDATE DISTINCTROW Orders SET Status = 'H', [Date Printed] = Date() WHERE RecordID = " & tempID & "" dim conntemp, rstemp set conntemp=server.createobject("adodb.connection") conntemp.open strconn conntemp.execute(mySQL) set rstemp=conntemp.execute(mySQL) 'rstemp.close set rstemp=nothing conntemp.close set conntemp=nothing Response.Write("Updated Record: " &tempID & "<br>") END IF NEXT%> Sorry, but there's no DRW code here folks - only ASP. Notice how I checked the form checkbox before I did the update. There are probably more elegant and efficient ways (this is pretty much 'brute force'), but this does work. Of course, you'll have to substitute your enviromental stuff for mine. Hope it helps...
|
|
|
|
Topic Starter
Posts: 49 From: Canada, eh? Status: offline
|
RE: Updating using checkboxes - 2/27/2002 10:55:46
Thanks, I'll give it a whirl!
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|