以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  紧急求助,关于数据岛的使用问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=34575)


--  作者: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">&nbsp;</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>


--  作者:Qr
--  发布时间:6/19/2006 3:28:00 PM

--  
以下是引用citicrc在2006-6-19 11:49:00的发言:
顺便也帮我看看这贴子的问题行吗?
http://bbs.xml.org.cn/dispbbs.asp?boardID=1&ID=34575


不好意思,偶很少用数据岛,最多会按正常的XML数据岛模式的引用方式简单运用:)

偶觉得是datasrc 和 datafld的用法有问题,改用setAttribute也不行,郁闷中...

citicrc兄“转移爱好”写网站了?!


--  作者:citicrc
--  发布时间:6/19/2006 4:18:00 PM

--  
不是啊乔瑞兄。因为忙,那边已经好久不去了。最近转J2EE中,然后发现AJAX的模式有时候很管用,如果这个通用的建表的包能做好的话,就不用写界面了,直接用AJAX截XML串,然后动态建TABLE,这样展示表格用的无数界面只要一个WEB页就能搞定。那以后每回要写表格的话,只要直接改CSS文件就行了。是个好办法。但现在在这个地方卡壳了。
--  作者:Qr
--  发布时间:6/20/2006 9:22:00 AM

--  
偶写了一段时间AJAX代码,觉得太辛苦了,主要是代码调试的问题。不过偶个从觉得VBS比JAVASCRIPT难得跟踪调试,所以现在基本上不再用VBS了。现在看你的代码,头都大了:)

现在最大的问题是,如何动态指定datasrc 和 datafld,再查资料看看吧。


--  作者:VictorWoo
--  发布时间:12/30/2006 9:43:00 AM

--  
以下是引用Qr在2006-6-20 9:22:00的发言:
偶写了一段时间AJAX代码,觉得太辛苦了,主要是代码调试的问题。不过偶个从觉得VBS比JAVASCRIPT难得跟踪调试,所以现在基本上不再用VBS了。现在看你的代码,头都大了:)

现在最大的问题是,如何动态指定datasrc 和 datafld,再查资料看看吧。



QR,我现在也在为写大量的JS发愁,不知你现在是用什么环境编写和调试的?
我用JSEclipse,调试实在没招,只有alert了
--  作者:Qr
--  发布时间:12/30/2006 3:13:00 PM

--  
以下是引用VictorWoo在2006-12-30 9:43:00的发言:
QR,我现在也在为写大量的JS发愁,不知你现在是用什么环境编写和调试的?
我用JSEclipse,调试实在没招,只有alert了


呵呵,偶也苦于找不到好用的调试工具,所以,每写一个FUNCTION,就用alert跟踪,而尽可能避免大批量调试。
--  作者:VictorWoo
--  发布时间:12/31/2006 2:00:00 PM

--  
昨天经朋友指点, internet选项->高级->禁用脚本调试 两个钩去掉
这样脚本出错的时候会弹框,要求选择调试器.安装了 office xp/2003 ,或者visual interdev 6, 或者 visual studio 2005,就会有一个很牛的调试器弹出来供选择。可以下断点,可以观察变量。下面就知道该怎么做了。
不过这只是调试器,编辑器还是没有找到合适的。
--  作者:VictorWoo
--  发布时间:8/2/2007 5:43:00 PM

--  
GoogleAdSense真的是蜘蛛?
--  作者:VictorWoo
--  发布时间:8/2/2007 5:44:00 PM

--  
寒,也碰到福州市鼓楼区的了。。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
171.875ms