用xmlHttp异步获取,我觉得放到onblur事件里比较好点,如果是onkeyup时间,查询数据库太频繁
1.首先你在这个页面显示学员收费记录的地方放个div(id="divReceive");
2.新建一个asp页面(aa.asp),根据学员编号(Request.QueryString("t1"),下面代码会传参数过来)
获得收费记录,Reponse.Write一个显示table
3.这里输入学员编号:<input type="text" name="sNo" id="sNo" onblur="eBlur(this)">
4.大概事件代码
var xmlHttpReq;
function eBlur(o)
{
if(o.value.replace(/\s+/g,"")=="")return;
if(window.XMLHttpRequest) //非IE浏览器 {
xmlHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject) //IE浏览器 {
xmlHttpReq=new ActiveXObject("Microsoft.XMLHttp");
}
if(xmlHttpReq) {
xmlHttpReq.open("GET", "http://.../aa.asp?t1="+o.value, false);
xmlHttpReq.onreadystatechange = callback;//回调函数
xmlHttpReq.send(null);
}
}function callback()
{
if(xmlHttpReq.readystate==4) //请求状态为4表示成功
{
if(xmlHttpReq.status==200) //http状态200表示OK
{
document.getElementById("divReceive").innerHTML = xmlHttpReq.responseText ;
}
else //http返回状态失败
{
alert("服务端返回状态:" + xmlHttpReq.statusText);
}
}
else //请求状态还没有成功,页面等待
{
document .getElementById ("divReceive").innerHTML ="数据加载中....";
}}
1.首先你在这个页面显示学员收费记录的地方放个div(id="divReceive");
2.新建一个asp页面(aa.asp),根据学员编号(Request.QueryString("t1"),下面代码会传参数过来)
获得收费记录,Reponse.Write一个显示table
3.这里输入学员编号:<input type="text" name="sNo" id="sNo" onblur="eBlur(this)">
4.大概事件代码
var xmlHttpReq;
function eBlur(o)
{
if(o.value.replace(/\s+/g,"")=="")return;
if(window.XMLHttpRequest) //非IE浏览器 {
xmlHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject) //IE浏览器 {
xmlHttpReq=new ActiveXObject("Microsoft.XMLHttp");
}
if(xmlHttpReq) {
xmlHttpReq.open("GET", "http://.../aa.asp?t1="+o.value, false);
xmlHttpReq.onreadystatechange = callback;//回调函数
xmlHttpReq.send(null);
}
}function callback()
{
if(xmlHttpReq.readystate==4) //请求状态为4表示成功
{
if(xmlHttpReq.status==200) //http状态200表示OK
{
document.getElementById("divReceive").innerHTML = xmlHttpReq.responseText ;
}
else //http返回状态失败
{
alert("服务端返回状态:" + xmlHttpReq.statusText);
}
}
else //请求状态还没有成功,页面等待
{
document .getElementById ("divReceive").innerHTML ="数据加载中....";
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货