asp 如何实现无刷新获取数据库中的值?
<td><inputtype=textname="number"id="number"onblur="upperCase()"></td><tdalign=leftwid...
<td><input type=text name="number" id="number" onblur="upperCase()"></td>
<td align=left width=31%>"name"的值</td>
在文本框内输入一个number的值,焦点离开后在下面的单元格中显示name的值,数据库表的字段number和name,谢谢各位高手,比较急! 展开
<td align=left width=31%>"name"的值</td>
在文本框内输入一个number的值,焦点离开后在下面的单元格中显示name的值,数据库表的字段number和name,谢谢各位高手,比较急! 展开
展开全部
//执行页面test.asp
<%
response.charset = "GB2312"
%>
<script type="text/javascript">
if(typeof XMLHttpRequest == "undefined" && window.ActiveXObject) {
function XMLHttpRequest() {
var a = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
for(var i=0; i<a.length; i++) {
try{
var oXMLHTTP = new ActiveXObject(a[i]);
return oXMLHTTP;
}catch(oError) {}
}
throw new Error("XMLHTTP");
}
}
function upperCase(ref) {
var oHTTP = XMLHttpRequest();
var path = "test2.asp"; //处理数据的网页
var path += "?num=" + ref.value;
oHTTP.open("get", path, true);
oHTTP.onreadystatechange = function() {
if(oHTTP.readyState == 4 && oHTTP.status == 200) {
document.getElementById("nameID").innerHTML = oHTTP.responseText;
}
};
oHTTP.send(null);
}
</script>
<td><input type=text name="number" id="number" onblur="upperCase(this)"></td>
<td align=left width="31%" id="nameID">"name"的值</td>
//处理页面test2.asp
<!--#include file="coon.asp" -->
<%
response.charset = "GB2312"
dim sName
sName = conn.execute("select name from 表名 where number = " & request("num"))(0)
response.write(sName)
%>
<%
response.charset = "GB2312"
%>
<script type="text/javascript">
if(typeof XMLHttpRequest == "undefined" && window.ActiveXObject) {
function XMLHttpRequest() {
var a = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
for(var i=0; i<a.length; i++) {
try{
var oXMLHTTP = new ActiveXObject(a[i]);
return oXMLHTTP;
}catch(oError) {}
}
throw new Error("XMLHTTP");
}
}
function upperCase(ref) {
var oHTTP = XMLHttpRequest();
var path = "test2.asp"; //处理数据的网页
var path += "?num=" + ref.value;
oHTTP.open("get", path, true);
oHTTP.onreadystatechange = function() {
if(oHTTP.readyState == 4 && oHTTP.status == 200) {
document.getElementById("nameID").innerHTML = oHTTP.responseText;
}
};
oHTTP.send(null);
}
</script>
<td><input type=text name="number" id="number" onblur="upperCase(this)"></td>
<td align=left width="31%" id="nameID">"name"的值</td>
//处理页面test2.asp
<!--#include file="coon.asp" -->
<%
response.charset = "GB2312"
dim sName
sName = conn.execute("select name from 表名 where number = " & request("num"))(0)
response.write(sName)
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询