-- 作者:citicrc
-- 发布时间:6/19/2006 11:00:00 AM
-- 紧急求助,关于数据岛的使用问题
先看这个,这个是正常的XML数据岛模式的引用方式 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head> <body> <table width="100%" height="372" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table id="tblresult" datasrc="#xmlresult" DATAPAGESIZE="21"> <thead> <tr bgcolor="#6b63E7"> <td height="2" colspan="7" align="center"></td> </tr> <tr align="center" bgcolor="#FFFFFF"> <td width="55" height="18" class="td1">客户号</td> <td width="1" height="18" bgcolor="#6b63E7"></td> <td width="120" height="18" class="td1">帐号</td> <td width="1" height="18" bgcolor="#6b63E7"></td> <td width="388" class="td1">户名</td> <td width="1" height="18" bgcolor="#6b63E7"></td> <td width="70" class="td1">名称</td> </tr> <tr bgcolor="#6b63E7"> <td height="1" colspan="7" align="center"></td> </tr> </thead> <tbody> <tr> <td width="55" height="18" align="center" class="td_kehuhao"><span datafld="客户号"></span></td> <td width="1" height="18" bgcolor="#6b63E7"></td> <td width="120" height="18" align="center" class="td_zhanghao"><span datafld="账号"></span></td> <td width="1" height="18" bgcolor="#6b63E7"></td> <td width="388" height="18" class="td_huming"><span datafld="户名"></span></td> <td width="1" height="18" bgcolor="#6b63E7"></td> <td width="70" height="18" align="right" class="td_jinger"><span datafld="名称"></span></td> </tbody> <tfoot> <tr bgcolor="#6b63E7"> <td height="2" colspan="7" align="center"></td> </tr> </tfoot> </table> </td> </tr> </table> </body> </html> <XML id="XMLRESULT"> <?xml version="1.0" encoding="GB2312"?> <Mydata> <结果> <客户号>10042</客户号> <账号>13849956</账号> <户名>福建省福州市鼓楼区XX公司</户名> <名称>dddd</名称> </结果> </Mydata> </XML> 那么接下来请问这种做法怎么就不行了,这段代码到底错在哪里?我觉得其中”mySpan.Datafld = myRec.Fields(i).value”这句似乎有些问题,可是又不知道具体该怎么写,就是不知道这种动态的决定TABLE的DATASRC,和动态的决定SPAN的DATAFLD有什么问题. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <script language="vbscript"> Private sub mytest() set myaa = document.all("TABLEID") set myTable = document.createElement("TABLE") with myTable .border = "0" .cellpadding = "0" .cellspacing = "0" .id = "tblresult" .datasrc = "#XMLRESULT" .DATAPAGESIZE = "21" end with myaa.appendChild(myTable) set myTHead = document.CreateElement("tHead") myTHead.id = "myTH" tblresult.appendChild(myTHead) set myXML = document.all("XMLRESULT") Set myRec = myXML.RecordSet myRec.MoveFirst myColCu = (myRec.Fields.Count-1)*2-1 set myTr = document.CreateElement("Tr") myTr.Id = "MYThTr1" myTH.appendChild(myTr) set myTd = document.CreateElement("Td") with myTd .Id = "MyThTr1Td" .bgColor = "#000000" .height = "2" .colspan = myColCu end with MYThTr1.appendChild(MyTd) set myTr = document.CreateElement("Tr") with myTr .bgColor = "#ffffff" .Id = "MYThTr2" .height = "18" end with myTH.appendChild(myTr) for i=0 to myRec.Fields.Count-2 set myTd = document.CreateElement("Td") with myTd .Id = "MyThTr2Td"&cStr(i+1) end with set myText = document.CreateTextNode(myRec.Fields(i).name) myTd.appendChild(myText) MYThTr2.appendChild(MyTd) if i <> myRec.Fields.Count-2 then set myTd = document.CreateElement("Td") with myTd .Id = "MyThTr2Td"&cStr(i+1+myRec.Fields.Count-1) .bgColor = "#000000" .width = "1" end with MYThTr2.appendChild(MyTd) end if next set myTr = document.CreateElement("Tr") myTr.Id = "MYThTr3" myTH.appendChild(myTr) set myTd = document.CreateElement("Td") with myTd .Id = "MyThTr3Td" .bgColor = "#000000" .height = "1" .colspan = myColCu end with MYThTr3.appendChild(MyTd) set myTBody = document.CreateElement("tBody") myTBody.id = "myTB" tblresult.appendChild(myTBody) set myTr = document.CreateElement("Tr") with myTr .Id = "MYTbTr1" .height = "18" end with myTH.appendChild(myTr) for i=0 to myRec.Fields.Count-2 set myTd = document.CreateElement("Td") with myTd .Id = "MyTbTr1Td"&cStr(i+1) end with set mySpan = document.CreateElement("SPAN") mySpan.Datafld = myRec.Fields(i).value myTd.appendChild(mySpan) MYTbTr1.appendChild(MyTd) if i <> myRec.Fields.Count-2 then set myTd = document.CreateElement("Td") with myTd .Id = "MyTbTr1Td"&cStr(i+1+myRec.Fields.Count-1) .bgColor = "#000000" .width = "1" end with MYTbTr1.appendChild(MyTd) end if next set myTFoot = document.CreateElement("tFoot") myTFoot.id = "myTF" tblresult.appendChild(myTFoot) set myTr = document.CreateElement("Tr") with myTr .Id = "MYTfTr1" end with myTF.appendChild(myTr) set myTd = document.CreateElement("Td") with myTd .Id = "MyTfTr1Td" .bgColor = "#000000" .height = "2" .colspan = myColCu end with MYTfTr1.appendChild(MyTd) tblresult.refresh() end sub </script> </head> <body> <table width="100%" height="372" border="0" cellpadding="0" cellspacing="0"> <tr> <td id="TABLEID"> </td> </tr> </table> <form name="form1" method="post" action=""> <input type="button" name="Submit" value="按钮" onclick="mytest()"> </form> </body> </html> <XML id="XMLRESULT"> <?xml version="1.0" encoding="GB2312"?> <Mydata> <结果> <客户号>10042</客户号> <账号>13849956</账号> <户名>福建省福州市鼓楼区XX公司</户名> <名称>dddd</名称> </结果> </Mydata> </XML>
|