我有一个ASP Classic页面,它有一个按钮,然后打开一个弹出窗口(现在只是一个测试)来执行查询。但是,此查询永远不会执行(Response.Write
也未显示)。为什么这不执行?
以下是主页面的代码。我仔细检查并将正确的值传递给函数。
function clearAssignment(assignmentID,docrecid)
{
window.open("procclearassignment.asp?assignmentID="+assignmentID+"&docrecid="+docrecid,"",'width=375,height=220');
}
<INPUT TYPE="button" class = "sbtn" name="clearassignment" Value="Clear" target="_self" onclick = "clearAssignment(<%=assignmentID%>,<%=docrecid%>);"/>
以下是流程:
<!--#include file="content/securityheader.asp"-->
<!--#include file="connection.inc"-->
<!--#include file="connectionxref.inc"-->
<!--#include file="securityheader.asp"-->
<!--#include file="connectionSQL.inc"-->
<% 'SQL SECURITY CODE
function dbencodeStr(str)
thestr = trim(replace(str,"'","'"))
thestr = trim(replace(thestr,"""","""))
thestr = trim(replace(thestr,"<","<"))
thestr = trim(replace(thestr,">",">"))
thestr = trim(replace(thestr,vbCRLF,"<BR>"))
dbencodeStr = thestr
end function
%>
<%
Server.ScriptTimeout=3600
'------------------------------
Function getName(str)
index = instr(str," ")
if index > 0 then
str = trim(mid(str,1,index))
end if
getName = str
End Function
'------------------------------
on error resume next
assignmentID = dbencodeStr(request.Form("assignmentID"))
docid = dbencodeStr(request.Form("docrecid"))
thedate = now()
if docid <> "" Then
''''Close any open assignments for the document
strSQL = "update RelDocAssignments set activeflag = 0, closedOn = getdate() where docid = '"&docid&"' and ID = '"&assignmentID&"';"
Set rs = objConnection.Execute(strSQL, ,adCmdText)
end if
Response.write(strSQL)
''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''
objConnection.close
set objConnection = nothing
objConnection2.close
set objConnection2 = nothing
objConnection3.close
set objConnection3 = nothing
%>
答案 0 :(得分:4)
您似乎通过url / querystring传递了您的值:
window.open("procclearassignment.asp?assignmentID="+assignmentID+...
但是你正在检索它们,好像它们被张贴了一样:
assignmentID = dbencodeStr(request.Form("assignmentID"))
我想你想要:
assignmentID = dbencodeStr(request.QueryString("assignmentID"))
代替。