共有两个文件tmh.htm & tt.xml
源代码如下:
tmh.htm
nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
New Document <script> <BR>//****************变量相关定义************** <BR>//* author:海仔 * <BR>//* Email:rautinee@21cn.com * <BR>//*本程序可自由传播使用,但请务必保留此信息* <BR>//**************************************** <BR>var pagenum=4; //每页显示几条信息 <BR>var page=0 ; <BR>var contpage ; <BR>var BodyText=""; <BR>var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); <BR>var mode="member"; <BR>var toolBar; <BR>xmlDoc.async="false" <BR>xmlDoc.load("tt.xml") <BR>//***************这个地方是你根据实际取得的字段名称来改了 <BR>header="<TABLE border=1><tr><td>姓名<td>图标<td>IP地址<td>email<td><td>日期<td><td>"; <BR>//检索的记录数 <BR>maxNum = xmlDoc.getElementsByTagName(mode).length <BR> //每条记录的列数 <BR> column=xmlDoc.getElementsByTagName(mode).item(0).childNodes <BR> //每条记录的列数 <BR> colNum=column.length <BR> //页数 <BR> pagesNumber=Math.ceil(maxNum/pagenum)-1; <BR> pagesNumber2=Math.ceil(maxNum/pagenum); <BR>//上一个页面 <BR>function UpPage(page) <BR>{ <BR> thePage="前一页"; <BR> if(page+1>1) thePage="<A HREF='#' onclick='Javascript:return UpPageGo()'>前一页"; <BR> return thePage; <BR>} <BR>function NextPage(page) <BR>{ <BR> thePage="后一页"; <BR> if(page<pagesNumber) thePage="<A HREF='#' onclick='Javascript:return NextPageGo()'>后一页"; <BR> return thePage; <BR>} <BR>function UpPageGo(){ <BR>if(page>0) page--; <BR> getContent(); <BR> BodyText=""; <BR>} <BR>//当前的页数 <BR>function currentPage() <BR>{ <BR> var cp; <BR> cp="当前是第 "+(page+1)+" 页"; <BR> return cp; <BR>} <BR>//总共的页数 <BR>function allPage() <BR>{ <BR> var ap; <BR> ap='总共 '+(pagesNumber+1)+' 页'; <BR> return ap <BR>} <BR>function NextPageGo() <BR>{ <BR>if (page<pagesNumber) page++; <BR>getContent(); <BR> BodyText=""; <BR>} <BR>//显示分页状态栏 <BR>function pageBar(page) <BR>{ <BR> var pb; <BR> pb=UpPage(page)+" "+NextPage(page)+" "+currentPage()+" "+allPage()+selectPage(); <BR> return pb; <BR>} <BR>function changePage(tpage) <BR>{ <BR>page=tpage <BR> if(page>=0) page--; <BR> if (page<pagesNumber) page++; <BR> getContent(); <BR> BodyText=""; <BR>} <BR>function selectPage() <BR>{ <BR> var sp; <BR> sp="<select name='hehe' onChange='javascript:changePage(this.options[this.selectedIndex].value)'>"; <BR> //sp="<select name='hehe' onChange='alert(this.options[this.selectedIndex].value)'>"; <BR> sp=sp+"<option value=''>"; <BR> for (t=0;t<=pagesNumber;t++) <BR> { <BR> sp=sp+"<option value='"+t+"'>"+(t+1)+""; <BR> } <BR> sp=sp+"" <BR> return sp; <BR>} <BR>function getContent() <BR>{ <BR>if (!page) page=0; <BR> n=page*pagenum; <BR> endNum=(page+1)*pagenum; <BR> if (endNum>maxNum) endNum=maxNum; <BR> BodyText=header+BodyText; <BR> for (;n<endNum;n++) <BR> { <BR> <BR> BodyText=BodyText+"<TR>"; <BR> for (m=0;m<=colNum-1;m++) <BR> { <BR> mName=column.item(m).tagName; <BR> BodyText=BodyText+("<TD>"+xmlDoc.getElementsByTagName(mName).item(n).text+""); <BR> } <BR> BodyText=BodyText+"" <BR> mm=""; <BR> } <BR> showhtml.innerHTML=BodyText+""+pageBar(page); <BR>BodyText="" <BR>} <BR></script>
<script> <BR>if (maxNum==0) <BR> { <BR> document.write("没有检索到合适的人才信息") <BR> } <BR> else <BR> { <BR> getContent() <BR> } <BR></script>
//下面是tt.xml的代码
海仔
rautinee
rautinee@btamail.net.cn
刚强
hehe
rautinee@chinamanagers.com
金华刚
nature_it
rautinee_sea@hotmail.com
的简强
tank
tank@163.com
合资
kaka
kaka@eyou.com
加个人
apple
apple@163.com
null
sunny
rautinee@eyou.com
宝贝
index
rautinee@21cn.com
null
login
webmaster@chinamanagers.com
jiang
123
japing@chianmanagers.com
null
world
rautinee@21cn.com
null
swallow
swallow@chinamanagers.com
魏格
hotmail
rautinee_sea@hotmail.com
null
wrong
wrong@chinamanagers.com
null
leah
leah@chinamanagers.com
null
ttth
rautinee@21cn.com
目前好像是只支持>IE5.0
如果你有什么好的方法和改进,请来信通知我,谢谢。