This one is driving me nuts!! A simple ASP page named Admin_DocList.asp. Connection to database is OK. Requests documents from recordset and displays OK. Then "onClick" link (with appropriate underline and hand cursor) to delete document from recordset--starts javascript function that captures the DocumentID and navigates the window to trigger the If clause of the Query string that deletes the document. Everything works but the documents aren't deleted from the database. It's not a javascript error--it has to be in the piece that connects the javascript to the ASP (The "action"="del") but I'll be darned if I can find my error.
Thanks,
Mike
<%
dim strConn
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/Document.mdb")
dim adoCn
dim strSQL
set adoCn = Server.CreateObject("ADODB.Connection")
adoCn.Open strConn
if Request.QueryString("action")="del" then
strSQL = "DELETE FROM Documents where DocumentID=" & Request.QueryString("DocumentID")
adoCn.Execute strSQL
end if
dim adoRs
set adoRs = Server.CreateObject("ADODB.Recordset")
strSQL = "Select * From Documents order by DocumentID Desc"
set adoRs = adoCn.Execute(strSQL)
%>
<html>
<body style="FONT-FAMILY: Verdana;FONT-SIZE: x-small;">
<font size=3><b>My Documents</b></font>
<font size=1>(<A HREF="admin_DocAdd.asp">Create New Document</A>)</font>
<ul>
<%
Do While Not adoRs.EOF%>
<li>
<%=adoRs("Title")%>
<br>
<font size=1>
<%=adoRs("DateCreated")%>
[<a href="admin_DocEdit.asp?DocumentID=<%=adoRs("Docum entID")%>">edit</a>]
[<span style="cursor:hand;TEXT-DECORATION: underline" onclick="DelDocument(<%=adoRs("DocumentID")%>);">d el</span>]
</font>
<br>
</li>
<%
adoRs.MoveNext
Loop%>
</ul>
<script language=JavaScript>
function DelDocument(DocumentID)
{
if (confirm("Delete this document ?") == true)
{
window.navigate("admin_DocList.asp?action=del&Docu mentID="+DocumentID);
}
}
</script>
</body>
</html>
<%
adoRs.Close
set adoRs = nothing
adoCn.Close
set adoCn = nothing
%>


Reply With Quote
Bookmarks