
Call Server Side Script From Client Side Script
I want to run the DeleteRecords sub when a user clicks the delete button and
answers yes to the question about if they are sure they want to delete. The
code never makes it inside the If statement on the server side where the
delete happens, the value of "rtn" doesn't get passed to the server side.
Do you know how I can do this? I want to be able to get a response from the
user before doing a delete. Thanks.
<SCRIPT RUNAT=Server LANGUAGE="VBScript">
Sub DeleteRecords
Response.Write ("Before Delete " & Request("rtn"))
If Request("rtn") = vbYes and Len(Trim(txtItem_ID.value)) <> 0 Then
Response.Write ("In Delete " & Request("rtn"))
'Delete all of the Counties in County Restriction table for the
'current Item_ID.
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DSN=FmDS;"
SQLStmt = "DELETE FROM County_Restrictions "
SQLStmt = SQLStmt & "WHERE (Item_ID = " & txtItem_ID.value & ")"
Set rs = Conn.Execute(SQLStmt)
'Delete all of the Items in Items table for the
'current Item_ID.
SQLStmt = "DELETE FROM Items "
SQLStmt = SQLStmt & "WHERE (Item_ID = " & txtItem_ID.value & ")"
Set rs = Conn.Execute(SQLStmt)
Set rs = Nothing
Conn.Close
Set Conn = Nothing
End If
End Sub
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
Function btnDelete_onclick()
'Delete record.
rtn = MsgBox("Are you sure you wish to Delete?",
vbYesNo+vbQuestion+vbDefaultButton2,"Delete Record?")
If rtn = vbYes Then
<%DeleteRecords%>
Else
Exit Function
End If
End Function
</SCRIPT>