Use this code:
Code:
<%
'Declare variables first!
Dim Conn, rs, SQl, msg
'Create Connection and RecordSet Objects
Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
'Open Connection And RecordSet Objects...
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("## DATABASE PATH HERE!!! ##")
If (Request.Form("strAction") <> "" AND Request.Form("strID") <> "") Then
Conn.Execute("DELETE FROM Basket WHERE ID=" & Replace(Request.Form("strID"),"'","''"))
msg = "<div style=""font-family:verdana;color:red;clear:both;font-size:11px;"">Item deleted!</div>"
End If
SQl = "SELECT * FROM Basket"
rs.Open SQl, Conn, 1
%>
<script language="javascript" type="text/javascript">
<!--
function deleteItem(itemId)
{
var theForm;
theForm = document.forms["fm"];
if (!theForm) {
theForm = document.fm;
}
if (confirm("Are you sure you want to delete this item?")) {
theForm.strAction.value = "delete";
theForm.strID.value = itemId;
theForm.submit();
}
}
//-->
</script>
<form name="fm" action='<%= Request.ServerVariables("Script_Name") & "?" & Request.QueryString %>' method="post" style="font-family:verdana;font-size:11px;">
<input type="hidden" name="strAction" value="" />
<input type="hidden" name="strID" value="" />
<table width="100%" border="1" style="font-family:verdana;font-size:11px;">
<tr>
<td width="55">ID</td>
<td width="650">Brand and Model</td>
<td width="20">Price</td>
<td width="60">Options</td>
</tr>
<%
Dim strId
While Not rs.EOF
strId = rs("ID")
%>
<tr>
<td width="55"><%= rs("ID") %></td>
<td width="193"><%= rs("Brand") %></td>
<td><%= rs("Price") %></td>
<td width="60"><input type="button" style="font-family:verdana;font-size:11px;" value="Delete" onclick="deleteItem('<%= strId %>')" /></td>
</tr>
<%
rs.MoveNext
WEnd
%>
</table>
<%= msg %>
</form>
<%
rs.Close
Conn.Close
Set rs = Nothing
Set Conn = Nothing
%>
Bookmarks