"Mike P" wrote:
I have very little experience of Classic ASP, but I need to take some
data from a table, write it to the screen in a tabular format, show a
check box at the end of every row, and write some code to enable the
user to check all check boxes, and then some code to respond to a button
click to find out which rows were checked.
Well, the "check all check boxes" will be JavaScript code, in the browser,
nothing to do with ASP.
And you don't say *WHAT* the code that "respond[s] to a button click" is
supposed to do. Just say "You checked boxes 17, 33, and 42"??? Or delete
records from the DB? Or copy records?
In other words, does the response need to be JS in the browser or ASP code
on the server?
*ASSUMING* you mean that you want to (say) delete all the checked records,
it's pretty easy.
Since you give us so little info about your app, I'll make some simplistic
assumptions. I'm doing it all on one page. So the <formsubmits back to
the same page and, if there are an records to be deleted, they are deleted.
Whether a delete occurred or not, all the non-deleted records are shown with
checkboxes.
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "...your connection string..."
If Trim( Request("DELETE") ) <"" Then
' submit was pushed, delete all checked records
SQL = "DELETE FROM people WHERE id IN (" & Request("ZAP") & ")"
howMany = -1
conn.Execute SQL, howMany
Response.Write "<h2>Deleted " & howMany & " records</h2><P>"
End If
%>
<form method="POST">
<table border=1 cellpadding=5>
<%
SQL = "SELECT ID, Name, Address FROM people"
Set RS = yourAlreadyOpenConnection.Execute( SQL )
Do Until RS.EOF
%>
<tr>
<td><%=RS("Name")%></td>
<td><%=RS("Address")%></td>
<td><input type=checkbox name="ZAP" value="<%=RS("ID"%>"></td>
</tr>
<%
RS.MoveNext
Loop
%>
</table>
<input type=submit value="Delete checked people" name="DELETE">
</form>
And that's all there is to it. Presto.
p.s.: Assumes the the ID field is a numeric field. Minor change needed if
it's a text field.