日期:2014-05-17  浏览次数:20780 次

SQL检索文本框-在文本框右侧显示数据库查询值!
有这样一个文本框!

我想通过失去焦点的方式去检索数据库。

当我在文本框中输入值后,我鼠标失去焦点,在文本框右侧显示数据库检索出来的值!

求高手帮忙解决,谢谢!

------解决方案--------------------
呵呵,最好的方法用ajax
研究一下使用ajax写的用户注册方法,其中有个用户名称检测,就是这个做法
------解决方案--------------------
不会用ajax就这样:

<input type= "text " onblur= "if (this.value != ' ' && this.value.length > 2){checkuser.location.href = 'checkuser.asp?username= ' + this.value;}else{return false;} " /> <div id= "d "> </div>
<iframe name= "checkuser "> </iframe> '把iframe隐藏掉

checkuser.asp:

<%
dim s '结果
s = " "
if Request.querystring( "username ") <> " " then
s = "no " '判断后,有此用户
else
s = "ok " '判断后,无此用户名
end if

if s <> " " then
response.write " <script> top.document.getElementById( 'd ').innerHTML = ' " & s & " '; </script> "
end if
%>