top
Loading...
XML介紹系列篇八
XML介紹系列之十五

翻譯:Batman
系列之十五: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=#xmldso DATAFLD="TITLE"></SPAN></td></tr>
<tr><td>Artist:</td><td><SPAN ID="artist" DATASRC=#xmldso DATAFLD="ARTIST"></SPAN></td></tr>
<tr><td>Year:</td><td><SPAN ID="year" DATASRC=#xmldso DATAFLD="YEAR"></SPAN></td></tr>
<tr><td>Country:</td><td><SPAN ID="country" DATASRC=#xmldso DATAFLD="COUNTRY"></SPAN></td></tr>
<tr><td>Company:</td><td><SPAN ID="company" DATASRC=#xmldso DATAFLD="COMPANY"></SPAN></td></tr>
<tr><td>Price:</td><td><SPAN ID="price" DATASRC=#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=#xmldso DATAFLD="TITLE"></SPAN></td></tr>
<tr><td>Artist:</td><td><SPAN ID="artist" DATASRC=#xmldso DATAFLD="ARTIST"></SPAN></td></tr>
<tr><td>Year:</td><td><SPAN ID="year" DATASRC=#xmldso DATAFLD="YEAR"></SPAN></td></tr>
<tr><td>Country:</td><td><SPAN ID="country" DATASRC=#xmldso DATAFLD="COUNTRY"></SPAN></td></tr>
<tr><td>Company:</td><td><SPAN ID="company" DATASRC=#xmldso DATAFLD="COMPANY"></SPAN></td></tr>
<tr><td>Price:</td><td><SPAN ID="price" DATASRC=#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>