Ted Ljong said:
Hi Jim
Did I misunderstood you? I appreciate some help with ASP
Ted Ljong.
Well, if you've written your own ASP page to display the existing
records, I presume you open a recordset containing the records you
want, and then run a loop that creates an HTML table row to display
each record. Here's an example.
<form method="POST" action="delete.asp">
<table>
<tr>
<th>ID</th>
<th>Decription</th>
</tr>
</table>
<%
do until rs.eof
%><tr>
<td><%=rs("recid")%></td>
<td><%=rs("description")%></td>
</tr><%
rs.movenext
loop
%>
<input name="bthDel" type="submit" value="Delete">
</form>
Add a column to that table and then, within the loop, emit an
additional table cell that emits the check box. Be sure to include the
identity of each record in the name of the check box. The loop will
now look like this.
do until rs.eof
%><tr>
<td><input type="checkbox" name="del<%=rs("recid")%>"
value="ON"></td>
<td><%=rs("recid")%></td>
<td><%=rs("description")%></td>
</tr><%
rs.movenext
loop
To see how this works, imagine that the visitor selects the check
boxes for record IDs 5, 10, and 20. In the page that processes the
form, the following expressions will then equal ON.
Request.Form("del5")
Request.Form("del10")
Request.Form("del20")
The page that processes the form should therefore contain this code:
if request.form("bthDel") <> "" then
for each name in request.form
if left(name,3) = "del" then
delid = mid(name,4)
sql = "DELETE from mytable WHERE recid = " & delid & " "
conn.Execute sql
response.write "<p>" & delid & "</p>"
end if
next
end if
Note that unchecked boxes transmit nothing. Thus, if the form contains
a checkbox named del17 and the visitor doesn't clear it, there will be
no such name as del17 in the request.form collection.
To "harden" this application you could, however, check each
Request.Form("del...") entry for a value of ON, or whatever you like.
You should also check each record ID for valid syntax.
If this is way over your head, you probably need to read some books or
get some training in ASP or ASP.NET programming. Tutoring by newsgroup
really isn't practical.
Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*------------------------------------------------------*
|\----------------------------------------------------/|
|| Microsoft Office FrontPage 2003 Inside Out ||
|| Microsoft FrontPage Version 2002 Inside Out ||
|| Web Database Development Step by Step .NET Edition ||
|| Troubleshooting Microsoft FrontPage 2002 ||
|| Faster Smarter Beginning Programming ||
|| (All from Microsoft Press) ||
|/----------------------------------------------------\|
*------------------------------------------------------*