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

ASP
ASP调用ORACLE存储过程并返回结果集
用ASP实现网页BBS
关于Global.asa文件的深入研究与session变量失效提示的具体方法
简易ASP+注册系统
防护手册:如何防止ASP木马在服务器上运行
用Visual Basic实现多画面播放功能之二
如何增强ASP程序性能(1)
如何增强ASP程序性能(2)
如何增强ASP程序性能(3)
ASP备份数据库
二十八条改善 ASP 性能和外观的技巧
在Form域中Post大于100K的数据
如何使用ASP制作模似动态生长的表单?
Microsoft IIS 真的如此「不安全」吗?(1)
Microsoft IIS 真的如此「不安全」吗?(2)
Microsoft IIS 真的如此「不安全」吗?(3)
Microsoft IIS 真的如此「不安全」吗?(4)
Microsoft IIS 真的如此「不安全」吗?(5)
关于页面和代码分离
ServerVariables 对路径的操作

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 80 ::
收藏到网摘: 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