index.html
<HTML>
<HEAD>
<TITLE>RS技术的实现例子</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
td.head {background-color:#3366cc;color:#ffffff}
</style>
</HEAD>
<BODY bgColor=LightGoldenrodYellow>
<script language="JavaScript" src="http://3344net/_ScriptLibrary/rs.htm"></script>
<script language="JavaScript">
RSEnableRemoteScripting("http://3344net/_ScriptLibrary");
</script>
<h1>客户信息</h1>
<hr>
<form name="MyForm">
<p><input type="text" name="state" size="20"> <input type=button value="提 交" name=btnExecute onclick="execAsynch(state.value)"></p>
</form>
<div id=num></div>
<div id=change></div>
<hr>
<SCRIPT LANGUAGE="JScript">
var serverURL = "http://3344net";
var pageURL = "/rs/Data.asp";
function refreshPage(co)
{
if (co.status != 0) {
alert("发生异常错误\n" +
message);
}
strText = co.return_value.split("|");
if (strText == "") {
document.all.change.innerHTML="<table><tr><td class=head>没有找到!!!</td></tr></table>";}
else{
document.all.num.innerHTML="共找到" +strText[0]+ "纪录<br>";
document.all.change.innerHTML="<table border=1 cellpadding=0 cellspacing=0 width=473><tr><td width=197 class=head><p align=center><b>客户</b></td><td width=276 height=24 class=head><p align=center><b>地址</b></td></tr>"+strText[1]+"</table>";
}
}
function execAsynch(state)
{
RSExecute(serverURL+pageURL, "GetEmpInfoAsArray", state, refreshPage);
}
</SCRIPT>
</BODY>
</HTML>
data.asp
<%@ LANGUAGE=VBSCRIPT %>
<% RSDispatch %>
<SCRIPT RUNAT=SERVER Language=javascript>
<!--#INCLUDE VIRTUAL="/_ScriptLibrary/RS.ASP"-->
function Description()
{
this.GetEmpInfoAsArray = DoGetData;
}
public_description = new Description();
function DoGetData(getstate)
{
var objConn = Server.CreateObject("ADODB.Connection");
objConn.Open("dsn=NW;Network=3344net");
var rst = Server.CreateObject("ADODB.Recordset");
rst.Open("SELECT 公司名称,地址 FROM 客户 Where [地区]=@#" + getstate + "@#", objConn, 1, 1);
count = rst.RecordCount;
strText = count + "|";
for (var j=0;j<count;j++)
{
strText += "<tr><td>" + rst("公司名称") + "<td>" + rst("地址");
rst.MoveNext();
}
objConn.Close();
return strText;
}
</SCRIPT>
文章来源于领测软件测试网 https://www.ltesting.net/