日期:2014-05-20 浏览次数:20952 次
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" import="hrm.lmwj.dao.*" errorPage="" %> <% Connection conn=DB.getConnection(); Statement stmt=null; stmt=conn.createStatement(); String sql=""; sql="select * from userInfo"; ResultSet rs=stmt.executeQuery(sql); int userId=-1; String usersName=""; String trueName=""; String gender=""; String depart=""; String tel=""; String born=""; String email=""; String post=""; String xueli=""; %> <html> <head> <title>员工基本信息查询</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/STYLE.CSS" rel="stylesheet"> </head> <body onLoad="javascript:Mycheck()"> <%//通过以下代码实现将数据库中的信息存放到数据岛中%> <xml id="xmldao"> <users> <% try{ while(rs.next()){ userId=rs.getInt("userId"); trueName=rs.getString("trueName"); gender=rs.getString("gender"); depart=rs.getString("department"); post=rs.getString("post"); xueli=rs.getString("xueli"); born=rs.getString("born"); tel=rs.getString("telephone"); email=rs.getString("email"); %> <userId><%=userId %> <trueName> <%=trueName%></trueName> <gender><%=gender %></gender> <depart><%=depart %></depart> <post><%=post %></post> <xueli><%=xueli %></xueli> <born><%=born %></born> <tel><%=tel %></tel> <email><%=email %></email> </userId> <%} }catch(Exception e){System.out.println(e.getMessage());}%> </users> </xml> <%DatabaseUtils.release(conn, stmt, rs);%> <table width="610" height="236" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="7" colspan="3" background="images/shop_12.gif"></td> </tr> <tr> <td width="93" height="50" background="images/shop_15.gif"> </td> <td colspan="2" valign="top" background="images/shop_16.gif"> <form name="form2" method="post" action=""> <table width="100%" height="23" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" height="7"></td> </tr> <tr> <td width="85%">请输入查询条件: <input name="key" type="text" class="txt_grey" size="33"> </td> <td width="15%"><input name="search" type="button" class="btn_grey" value="搜索" onClick="javascript:Mycheck1()"></td> </tr> </table> </form> </td> </tr> </table> <table width="100%" border="1" id="table1"> </table></td> </tr> </table> <Script Language="JavaScript"> function Mycheck(){//初始化下拉框 var Emname; firstElement=xmldao.childNodes.item(0);//用于返回第一个元素 for(var i=0;i<firstElement.childNodes.length;i++){ prevailnode=firstElement.childNodes(i); for(var j=0;j<prevailnode.childNodes.length;j++){ DD=prevailnode.childNodes(j).nodeName; if(DD=="userName"){ Emname=prevailnode.childNodes(j).text; } } //所符合条件的信息写进select中 if(Emname!=""){ var message = document.createTextNode(Emnanme); var td = document.createElement("td"); td.appendChild(message); var tr = document.createElement("tr"); tr.appendChild(td); var tbody = document.createElement("tbody"); tbody.appendChild(tr); var table = document.createElement("table"); table.appendChild(tbody); document.body.appendChild(table); } } } //从数据岛中检索数据,并将其装入到列表框中 /*function Mycheck1(){ var Emname; Emname=""; text0=form2.key.value; //清除列表框 /* count0=result.length for(i=count0-1;i>=0;i--){ result.remove(i); }*/ /* firstElement=xmldao.childNodes(0); for(i=0;i<firstElement.childNodes.length;i++){ prevailitem=firstElement.childNodes(i); for(j=0;j<prevailitem.childNodes.length;j++){ if(prevailitem.childNodes(j).nodeName=="trueName"){ ep=prevailitem.childNodes(j).text; } //查找相匹配的项 if(ep.indexOf(text0)!=-1){ Emname=ep; } if(Emname!=""){ op=document.createElement("option"); op.text=Emname; result.add(op); Emname=""; } } } }*/ </script> </body> </html>