当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp查询xml的代码,实现了无刷新、模糊查询功能

ASP
asp中利用数组实现数据库记录的批量录入方法
vbs(asp)的栈类
加密處理使密碼更安全[CFS編碼加密]
在asp中通过vbs类实现rsa加密与解密
披著羊皮的大野狼 - Session
简体中文编码对应器
len(),lift(),right()不能正常识别中文的解决方法
实现WEB中的@虚拟域名系统(原理篇)
巧用ASP生成PDF文件
二级域名原理以及程序,申请即可开通
无组件上传图片到数据库中,最完整解决方案
在ASP中使用SQL语句之1:SELECT 语句
在ASP中使用SQL语句之2:用WHERE子句设置查询条件
在ASP中使用SQL语句之3:LIKE、NOT LIKE和 BETWEEN
在ASP中使用SQL语句之4:联合语句
在ASP中使用SQL语句之5:开始执行
在ASP中使用SQL语句之6:存储查询
在ASP中使用SQL语句之7:ORDER BY
在ASP中使用SQL语句之8:随机数
在ASP中使用SQL语句之9:表单操作

ASP 中的 asp查询xml的代码,实现了无刷新、模糊查询功能


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 109 ::
收藏到网摘: n/a

 

<html>
<head>
<title>不刷新页面查询的方法</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script language="javascript">
<!--初始化,将数据岛中数据装入列表框中-->
 function loadinsel()
 {
   var employeeid,employeelastname;          //分别存放雇员ID和雇员名字
   root=document.all.xmlemployees.childNodes.item(0);  //返回第一个元素--employee
   for(i=0;i<root.childNodes.length;i++){
    getnode=root.childNodes(i);             //得到empolyee的一个子节点
     employeeid=root.childNodes(i).getAttribute("emid");//得到雇员ID
     for(j=0;j<getnode.childNodes.length;j++){
        employeeinf=getnode.childNodes(j).nodeName;
  if(employeeinf=="lastname"){
     employeelastname=getnode.childNodes(j).text;  //得到雇员名字
  }
 }
   //将得到的employeeid和employeelastname写进select中
  if(employeeid!="" && employeelastname!=""){
  option1=document.createElement("option");
  option1.text=employeelastname;
  option1.value=employeeid;
  employeelist.add(option1);
  } 
   }
 }
 
 <!--初始化,从数据岛中检索数据,装入列表框中-->
 function findemployee(){
     var employeelastname,employeeid;  //分别存放雇员名字和雇员ID
  employeelastname="";
  employeeid="";
     findtext=window.findcontent.value; //得到检索条件
  //清除列表框
  employeecount=employeelist.length
  for(i=employeecount-1;i>=0;i--){
      employeelist.remove(i);
  }
     root=window.xmlemployees.childNodes(0);
  for(i=0;i<root.childNodes.length;i++){
      getitem=root.childNodes(i);    //得到empolyee的一个子节点
   employeeid=root.childNodes(i).getAttribute("emid");  //得到雇员ID
   for(j=0;j<getitem.childNodes.length;j++){
       if(getitem.childNodes(j).nodeName=="lastname"){
        employee_temp=getitem.childNodes(j).text;
     if(employee_temp.indexOf(findtext)!=-1){  //查找匹配项
        employeelastname=employee_temp;     //找到名字匹配的雇员
     }
    
    }

       }
 //将符合条件的雇员信息写进select中
 if(employeeid!="" && employeelastname!=""){
    option1=document.createElement("option");
    option1.value=employeeid;
    option1.text=employeelastname;
    window.employeelist.add(option1);
    employeeid="";
    employeelastname="";
    } 
  }
 }
</script>
<body bgcolor="#FFFFFF" text="#000000" onload="javascript:loadinsel()">
<table width="80%" border="1">
  <tr>
    <td> 请输入查询条件:
<input type="text" name="findcontent">
      <input type="button" name="Submit" value="查找" onclick="javascript:findemployee()">
    </td>
  </tr>
  <tr>
    <td> 查询结果:
<select name="employeelist">
      </select>
    </td>
  </tr>
</table>
<?xml version="1.0" encoding="gb2312"?>
<%
  servername="wyb"            '服务器名
&n