XML数据岛的综合应用实例
2011-01-07 10:49
417 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<xml id="XMLDSO" src="book.xml"></xml>
<html>
<head>
<title>分页分条显示书本信息</title>
</head>
<script language="JavaScript">
var pageno=1;
var objbook=XMLDSO.recordset;
function SelectRecord(Element)
{
//获取记录的列号
RecordNo=Element.parentElement.rowIndex;
//建立XML的RecordSet
objbook=XMLDSO.recordset;
//指定当前的位置
objbook.absoluteposition=RecordNo+(pageno-1)*tblbooks.dataPageSize;
//获取元素的值
title.innerHTML = objbook("title").value;
bookcategory.innerHTML = objbook("bookcategory").value;
ISBN.innerHTML = objbook("ISBN").value;
author.innerHTML = objbook("author").value;
publisher.innerHTML = objbook("publisher").value;
price.innerHTML = objbook("price").value;
remain.innerHTML = objbook("remain").value;
}
function pre_page()
{
if(pageno>1)
{
tblbooks.previousPage();
pageno=pageno-1;
}
}
function next_page()
{
if(pageno<objbook.RecordCount/tblbooks.dataPageSize)
{
tblbooks.nextPage();
pageno=pageno+1;
}
}
</script>
<body>
<center><b>分页显示图书信息</b></center>
<table id="tblbooks" datasrc="#XMLDSO" border="1" align="center" datapagesize="3">
<thead>
<th>书名</th>
<th>类别</th>
<th>书号</th>
<th>作者</th>
<th>出版社</th>
<th>定价</th>
<th>剩余量</th>
</thead>
<tr>
<td onclick=SelectRecord(this)><span datafld="title"></span></td>
<td onclick=SelectRecord(this)><span datafld="bookcategory"></span></td>
<td onclick=SelectRecord(this)><span datafld="ISBN"></span></td>
<td onclick=SelectRecord(this)><span datafld="author"></span></td>
<td onclick=SelectRecord(this)><span datafld="publisher"></span></td>
<td onclick=SelectRecord(this)><span datafld="price"></span></td>
<td onclick=SelectRecord(this)><span datafld="remain"></span></td>
</tr>
</table>
<center>
<input type="button" onclick="pre_page()" value="上一页">
<input type="button" onclick="next_page()" value="下一页">
每一页<input type="text" value="3" size="5" onblur="tblbooks.dataPageSize=this.value;">笔
</center>
<center>请单击上面感兴趣的图书行</center>
<hr/>
<center>单本图书信息:书名:<span id="title"></span></center>
<table border="1" align="center">
<tr>
<td width="50%">
分类:<span id="bookcategory"></span><br>
书号:<span id="ISBN"></span><br>
作者:<span id="author"></span><br>
</td>
<td width="50%">
出版:<span id="publisher"></span><br>
定价:<span id="price"></span><br>
剩余:<span id="remain"></span><br>
</td>
</tr>
</table>
</body>
</html>
执行效果如下:
<xml id="XMLDSO" src="book.xml"></xml>
<html>
<head>
<title>分页分条显示书本信息</title>
</head>
<script language="JavaScript">
var pageno=1;
var objbook=XMLDSO.recordset;
function SelectRecord(Element)
{
//获取记录的列号
RecordNo=Element.parentElement.rowIndex;
//建立XML的RecordSet
objbook=XMLDSO.recordset;
//指定当前的位置
objbook.absoluteposition=RecordNo+(pageno-1)*tblbooks.dataPageSize;
//获取元素的值
title.innerHTML = objbook("title").value;
bookcategory.innerHTML = objbook("bookcategory").value;
ISBN.innerHTML = objbook("ISBN").value;
author.innerHTML = objbook("author").value;
publisher.innerHTML = objbook("publisher").value;
price.innerHTML = objbook("price").value;
remain.innerHTML = objbook("remain").value;
}
function pre_page()
{
if(pageno>1)
{
tblbooks.previousPage();
pageno=pageno-1;
}
}
function next_page()
{
if(pageno<objbook.RecordCount/tblbooks.dataPageSize)
{
tblbooks.nextPage();
pageno=pageno+1;
}
}
</script>
<body>
<center><b>分页显示图书信息</b></center>
<table id="tblbooks" datasrc="#XMLDSO" border="1" align="center" datapagesize="3">
<thead>
<th>书名</th>
<th>类别</th>
<th>书号</th>
<th>作者</th>
<th>出版社</th>
<th>定价</th>
<th>剩余量</th>
</thead>
<tr>
<td onclick=SelectRecord(this)><span datafld="title"></span></td>
<td onclick=SelectRecord(this)><span datafld="bookcategory"></span></td>
<td onclick=SelectRecord(this)><span datafld="ISBN"></span></td>
<td onclick=SelectRecord(this)><span datafld="author"></span></td>
<td onclick=SelectRecord(this)><span datafld="publisher"></span></td>
<td onclick=SelectRecord(this)><span datafld="price"></span></td>
<td onclick=SelectRecord(this)><span datafld="remain"></span></td>
</tr>
</table>
<center>
<input type="button" onclick="pre_page()" value="上一页">
<input type="button" onclick="next_page()" value="下一页">
每一页<input type="text" value="3" size="5" onblur="tblbooks.dataPageSize=this.value;">笔
</center>
<center>请单击上面感兴趣的图书行</center>
<hr/>
<center>单本图书信息:书名:<span id="title"></span></center>
<table border="1" align="center">
<tr>
<td width="50%">
分类:<span id="bookcategory"></span><br>
书号:<span id="ISBN"></span><br>
作者:<span id="author"></span><br>
</td>
<td width="50%">
出版:<span id="publisher"></span><br>
定价:<span id="price"></span><br>
剩余:<span id="remain"></span><br>
</td>
</tr>
</table>
</body>
</html>
执行效果如下:
相关文章推荐
- 工厂方法模式——23种设计模式综合实例应用
- SQL Server 应用开发 --- SQL SERVER 2000 数据查询综合实例
- cut、file、for、ls、的综合应用实例
- PDO综合实例应用
- UISegmentedControl ,UIStepper,UISwitch,UISlider综合应用(实例需求)
- ARM—Linux基本数据类型综合应用实例
- Linux入职基础-7.5_Makefile应用综合实例
- Linux C编程--进程间通信(IPC)6--综合应用实例--信号量和共享内存的使用
- Java回调以及线程综合应用实例
- JSP简单练习-包装类综合应用实例
- 线性表的综合应用实例
- Linux C编程--进程间通信(IPC)6--综合应用实例--信号量和共享内存的使用
- sed ‘N,P,D,lable循环’高级应用综合实例
- jquery综合应用实例
- 微信API实例(OKHttp+PullToRefreshListView+WebView综合应用)
- JDBC操作数据库――CRUD综合应用实例
- LinQ综合应用实例
- C++ 容器的综合应用的一个简单实例——文本查询程序
- js综合应用实例简单的表格统计
- 一维小波降噪的综合应用实例