我正在使用经典ASP应用程序,我从sql数据库中填充了html表,该html表在其中一个单元格中具有复选框,在复选框上单击“我正在打开一个弹出窗口,在其中进行一些更新并提交后” ,窗口将自动关闭,并且上一页将使用更新后的值刷新(此处的复选框将替换为更新后的值)。 与IE可以正常工作,但不能与其他浏览器进行更新。
对于测试弹出窗口,我注释了javascript窗口关闭,发现对于数据库中的IE数据更新,但在其他浏览器中则无作用。可能与ADODB设置有关。我要更新的数据是当前日期,一旦存储在数据库中,上一页将获得当前日期而不是复选框。
请帮助,我是经典asp的新手。 更新:我打印了查询,在IE上可以正确打印,但在Chrome浏览器中,它在打印第二个参数,右边带有一些空格。例如:在IE'SHP'中,但在Chrome'SHP'中
<!-- language: lang-js -->
function CloseWindow()
{
var trackerreport = document.getElementById("trackerreport").innerText;
var reporttype = document.getElementById("reporttype").innerText;
var report = reporttype.trim();
document.getElementById("Hidden1").value = trackerreport;
document.getElementById("Hidden2").value = reporttype;
switch (report)
{
case "SHP":
document.frmDtls.hfrom.value = 'DelSHP' ;
break;
case "WHS":
document.frmDtls.hfrom.value = 'DelWHS' ;
break;
default:
alert("None");
break;
}
document.frmDtls.method = "post" ;
document.frmDtls.action = "PRDB_UPDATE_BATCH_ORDER_PROCESSING_TRACKER_REPORT_SEGMENT_TIMESTAMP.asp" ;
document.frmDtls.submit();
window.close();
window.opener.location.reload();
}
<!-- language: lang-vb -->
<div align="center">
<p align="center">
<input type="button" style="background:yellow;color:black;height:25px; width:100px" value="Confirm" onclick="javascript: return CloseWindow();">
<!--<input type="submit" style="background:yellow;color:black;height:25px; width:100px" value="Confirm" > -->
<input type="button" style="background:yellow;color:black;height:25px; width:100px" value="Cancel" onclick="javascript: return CancelWindow();">
</p>
</div>
<%
Set objCommand = Server.CreateObject ("ADODB.Command")
Set objRec = Server.CreateObject ("ADODB.Recordset")
objCommand.ActiveConnection = strConnect
Dim sConn
Dim tracker
Dim reporttype
Dim trackernew
If Request("hfrom") = "DelSHP" Then
Set sConn = Server.CreateObject ("ADODB.Connection")
sConn.Open strConnect
tracker = Trim(Request("Hidden1"))
trackernew = CInt(tracker)
reporttype = Trim(Request("Hidden2"))
username = Trim(Request("Hidden3"))
objCommand.CommandText = "EXEC usp_UPDATE_BATCH_ORDER_PROCESSING_TRACKER_REPORT_SEGMENT '"&trackernew&"','"&reporttype&"','"&username&"'; "
Set objRecord = objCommand.Execute
sConn.Close
Set objRecord = Nothing
Set sConn = Nothing
End If
If Request("hfrom") = "DelWHS" Then
Set sConn = Server.CreateObject ("ADODB.Connection")
sConn.Open strConnect
tracker = Trim(Request("Hidden1"))
trackernew = CInt(tracker)
reporttype = Trim(Request("Hidden2"))
username = Trim(Request("Hidden3"))
objCommand.CommandText = "EXEC usp_UPDATE_BATCH_ORDER_PROCESSING_TRACKER_REPORT_SEGMENT '"&trackernew&"','"&reporttype&"','"&username&"'; "
Set objRecord = objCommand.Execute
sConn.Close
Set objRecord = Nothing
Set sConn = Nothing
End If
%>
<!-- language: lang-html -->
<div align="center"><center>
<form id="frmDtls" name="frmDtls">
<input type="hidden" name="hfrom" value = "">
<input id="Hidden1" name="Hidden1" type="hidden" runat="server" />
<input id="Hidden2" name="Hidden2" type="hidden" runat="server" />
<input id="Hidden3" name="Hidden3" type="hidden" runat="server" value="<%= l_username%>" />
<table border="2" width="50%">
<tr>
<td width="40%" align="center" bgcolor="#C0C0C0"><strong><font size="2">Tracker Report ID </font><small>:</small></strong></td>
<td id="trackerreport" width="60%" align="center" bgcolor="#C0C0C0"><strong><%=L_trackerreportid %></strong> </td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#C0C0C0"><strong><font size="2">Segment Status Event </font><small>:</small></strong></td>
<td id="reporttype" width="60%" align="center" bgcolor="#C0C0C0"><strong><%=L_reporttype %></strong> </td>
</tr>
</table>
</center></div>
答案 0 :(得分:0)
我已修复此问题,由于某些原因,javascript跳过了更新查询,并直接在Chrome上关闭了窗口。完成更新后,现在调用javascript close方法。
sConn.Close
Set objRecord = Nothing
Set sConn = Nothing
Response.Write("<script language=javascript>CancelWindow();</script>") // added this line