asp不刷新页面筛选数据库中的数据

时间:2009-03-26    点击:1632   
<html>
<head>
<title>不刷新页面查询的方法</title>
<meta http-equiv="Content-Type"content="text/html;charset=gb2312">
</head>
<script language="javascript">
  function search_onclick(){
  //得到筛选雇员的名字
  searchtext=window.searchContent.value;
 //首先移除在所有查询结果列表中的选项
 j=searchObj.length;
 for(i=j-1;i>=0;i--)
 {
  searchObj.remove(i);
  }
 if(searchtext!=""){
 //显示符合筛选条件的雇员
 j=searchSource.length;
 for(i=0;i<j;i++){
 searchsource=searchSource.options(i).text;
 k=searchsource.indexOf(searchtext);
 if(k!=-1){
  option1=document.createElement("option");
  option1.text=searchsource;
  option1.value=searchSource.options(i).value;
  searchObj.add(option1);
 }
 }
 }
 else{
 //如果没有输入查询条件则显示所有雇员
 j=searchSource.length;
 for(i=0;i<j;i++){
  searchsource=searchSource.options(i).text;
  option1=document.createElement("option");
  option1.text=searchsource;
  option1.value=searchSource.options(i).value;
  searchObj.add(option1);
 }
 }
 }
</script>
<body bgcolor="#FFFFFF" text="#000000">
<h3>不刷新页面查询的方法</h3>
<hr>
<%
set conn=server.CreateObject("adodb.connection")
'connstring =Application("ASP_Chapter05_Con1")
conn.Open "DRIVER=SQL Server;SERVER=(local);UID=sa;pwd=sa;DATABASE=northwind"
'conn.open connstring
set rs=server.CreateObject("adodb.recordset")
sql="Select employeeid,lastname from employees order by employeeid"
rs.Open sql,conn,1,3%>
<table width="80%" border="1" align="center">
<tr><td><input type="text" name="searchContent">
<input type="button" name="Button" value="查询" onclick="javascript:return search_onclick()">
</td></tr>
<tr>
<td>查询结果<br>
<select name="searchObj" size="10">
<%do while not rs.eof%>
<option value="<%=rs("employeeid")%>"><%=rs("lastname")%></option>
<%rs.movenext
loop
%>
</select>
<select name="searchSource" size="10" style="display:none">
<%
rs.movefirst
while not rs.eof 'do %>
<option value="<%=rs("employeeid")%>"><%=rs("lastname")%></option>
<%
rs.movenext
wend
'loop
%>
</select>
</td>
</tr>
</table>
<%rs.close
set rs=nothing
%>
</body>
</html>
GridView 隐藏列,visible="false"
用ASP提供的浏览器性能组件来辨别客户浏览器
asp使用Counters组件实现网站访问人数统计
如何在ASP中引用类
asp组件安装
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 All Rights Reserved