size=3>系列之十五:XML的運用(二)
還是接著上面的那個例子,這個例子來顯示
如何在那些記錄之間進行移動。
cd_navigate.htm文件:
<Html>
<head>
<script language="JavaScript">
function movenext()
{
if (XMLdso.recordset.absoluteposition < XMLdso.recordset.recordcount)
{
XMLdso.recordset.movenext();
}
}
function moveprevious()
{
if (XMLdso.recordset.absoluteposition > 1)
{
XMLdso.recordset.moveprevious();
}
}
</script>
<script for="window" event="onload">
XMLdso.XMLDocument.load("cd_catalog.XML");
</script>
<TITLE>CD Navigate</TITLE>
</head>
<body>
<p>
<object WIDTH="0" HEIGHT="0"
CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" ID="XMLdso">
</object>
<table>
<tr><td>Title:</td><td><SPAN ID="title" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="TITLE"></SPAN></td></tr>
<tr><td>Artist:</td><td><SPAN ID="artist" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="ARTIST"></SPAN></td></tr>
<tr><td>Year:</td><td><SPAN ID="year" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="YEAR"></SPAN></td></tr>
<tr><td>Country:</td><td><SPAN ID="country" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="COUNTRY"></SPAN></td></tr>
<tr><td>Company:</td><td><SPAN ID="company" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="COMPANY"></SPAN></td></tr>
<tr><td>Price:</td><td><SPAN ID="price" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="PRICE"></SPAN></td></tr>
</table>
<p>
<INPUT TYPE=button VALUE="Previous CD" ONCLICK="moveprevious()">
<INPUT TYPE=button VALUE="Next CD" ONCLICK="movenext()">
</p>
</body>
</Html>
翻譯:Batman
系列之十六:XML的運用(三)
一個稍微復雜點的運用,還是使用的第一個運用中的XML數據文件
注意當你現在使用鼠標點擊表格中的第一個字段時,
在上面的數據會相應地改變Title的內容。(當然你可以對它相應的改改
它就可以顯示其他字段的內容了。)
cd_application.htm文件:
<Html>
<head>
<script language="JavaScript">
function movenext()
{
if (XMLdso.recordset.absoluteposition < XMLdso.recordset.recordcount)
{
XMLdso.recordset.movenext();
}
}
function moveprevious()
{
if (XMLdso.recordset.absoluteposition > 1)
{
XMLdso.recordset.moveprevious();
}
}
</script>
<script for="window" event="onload">
XMLdso.XMLDocument.load("cd_catalog.XML");
</script>
<TITLE>CD Navigate</TITLE>
</head>
<body>
<p>
<object WIDTH="0" HEIGHT="0"
CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" ID="XMLdso">
</object>
<table>
<tr><td>Title:</td><td><SPAN ID="title" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="TITLE"></SPAN></td></tr>
<tr><td>Artist:</td><td><SPAN ID="artist" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="ARTIST"></SPAN></td></tr>
<tr><td>Year:</td><td><SPAN ID="year" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="YEAR"></SPAN></td></tr>
<tr><td>Country:</td><td><SPAN ID="country" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="COUNTRY"></SPAN></td></tr>
<tr><td>Company:</td><td><SPAN ID="company" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="COMPANY"></SPAN></td></tr>
<tr><td>Price:</td><td><SPAN ID="price" DATASRC=http://www.blue1000.com/article/#XMLdso DATAFLD="PRICE"></SPAN></td></tr>
</table>
<p>
<INPUT TYPE=button VALUE="Previous CD" ONCLICK="moveprevious()">
<INPUT TYPE=button VALUE="Next CD" ONCLICK="movenext()">
</p>
</body>
</Html>