以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML在软件工程中的应用 』  (http://bbs.xml.org.cn/list.asp?boardid=6)
----  如何用js得到xsl value-of select=""中数据呢;代码如下-----  (http://bbs.xml.org.cn/dispbbs.asp?boardid=6&rootid=&id=21969)


--  作者:malaoping
--  发布时间:9/7/2005 11:51:00 AM

--  如何用js得到xsl value-of select=""中数据呢;代码如下-----
<xsl:for-each select="/portal/portlet/other/form/listtitle/items/item">
    <th>
      <xsl:value-of select="colnote"/>
    </th>
    </xsl:for-each>
    </tr>
    
    <xsl:for-each select="/portal/portlet/other/form/listdata/items/item">
    <tr>
     <td><xsl:value-of select="dwmc"/> </td>
      <td><xsl:value-of select="bks"/> </td> 
   <td><xsl:value-of select="tzdbh"/> </td>
   <td><xsl:value-of select="bkrq"/> </td>
   <td><xsl:value-of select="lymc"/> </td>
   <td><xsl:value-of select="yt"/> </td>  
   <td><xsl:value-of select="dwdm"/> </td>  
    </tr>
 想问一下,我要得到colnote的值,在javascript中如何写---
              
--  作者:malaoping
--  发布时间:9/9/2005 9:55:00 AM

--  

具体的程序我贴出如下:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<%@ include file="../taglibs.jsp"%>
<xsl:template match="/">
  <html>
  <head>
  <title><spring:message code="query.bkqkbtable"/></title>
   
  </head>
  <body>
  <div id="dataviewtool" ondblclick="mixwindow()" alt="<spring:message code="query.winopen"/>">
  <a href="#" onclick="mixwindow()"><spring:message code="query.winopen"/></a></div>

  <div id="list">
  <script>
      var imgopen = false;
   function loadThreadFollow(t_id,a_id,b_id){
    
    var imgid = "followImg"+t_id;
    alert(imgid);
       var imgobj = document.getElementById(imgid);
    imgobj.src = "images/minus1.gif";
   }
   
   function mixwindow()
   {
   mypage=window.open('','mypage','scrollbars');
   mypage.moveTo(0,0)
   mypage.resizeTo(screen.width,screen.height)
   mypage.document.write(mypage.opener.document.getElementById('list').outerHTML);
   }
   

   function TurnToExcel()
   {
     var ls_msg =confirm("<spring:message code="query.toExcel.if"/>");
     if(ls_msg){
       
      window.open('/ExcelWriteController.do','','width=200,height=200');
      alert("Attention:"+"<spring:message code="query.toExcel.ok"/>");
     }
   }
   
   
   function CreateExcel()
   {
   // Declare the variables
   var Excel, Book;
   
   // Create the Excel application object.
   Excel = new ActiveXObject("Excel.Application");
   
   // Make Excel visible.
   //Excel.Visible = true;
   
   var ls_msg =confirm("<spring:message code="query.toExcel.if"/>");
       if(ls_msg){
     
   // Create a new work book.
   Book = Excel.Workbooks.Add();
   
   //date :display
     var s,d = new Date();
   s += (d.getMonth() + 1) + "/";
            s += d.getDate() + "/";
            s += d.getYear();
   alert("Today is "+s);
   
   // Place some text in the first cell of the sheet.
   Book.ActiveSheet.Cells(1,1).value = "This is column A, row 1";
   //Book.ActiveSheet.Cells(2,1).value = "This is column A, row 2";
   //Book.ActiveSheet.Cells(1,2).value = "This is column B, row 1";
   //Book.ActiveSheet.Cells(2,2).value = "This is column B, row 2";
   
   // 1.table title = colnote ; first row:
   //var t_title = document.getElementsByTagName("/portal/portlet/other/form/listtitle/items/item").nodevalue;
   //        alert(t_title);
            
               
   
   //  2.table data = ;
       //var t_data = document.getElementsByTagName('dwmc');
       //alert(t_data);
   
   // Save the sheet.
   Book.SaveAs("C:\\mazp\\TEST.XLS");
   
   // Close Excel with the Quit method on the Application object.
   Excel.Application.Quit();
   
   }
   
   }
   

              
  //我要在这里取出表头和数据;

     function  GetFieldData()
          {
            // 1.xsl: for-each  select ='' is  only to select the  node not the value of node  ;        
                               
               
            // 2.xsl:value-of select = '' is to get the node's value;
                     
            
           alert("table name is ");
       
          }

  </script>   
  <link href="theme/default.css" rel="stylesheet" type="text/css"/>
  <script src="js/js.js"></script>
  

  <TR>
     
     <!--http://localhost:7001/listBkqkbController.do?m_url=cxbkqkb&modalcode=05&linkmodalcode=050503 -->
     <!--how to get: m_url -->
     <!--how to get: modalcode-->
     <!--how to get:linkmodalcode-->
     <!--how to get:dwdm -->
     
     <TD>
     
     
          <a href="#" onclick="TurnToExcel()"><spring:message code="query.toExcel"/></a>
     
       <input id="toExcel" type="button" name="toExcel" value="<spring:message code="query.toExcel"/>" onclick="javascript:window.open('/ExcelWriteController.do','','scrollbars=yes, resizable=yes')"/>
          
       <a href="#" onclick="CreateExcel()">InPage<spring:message code="query.toExcel"/></a>
      
      
     <input id="creatExcel" type="button" name="createExcel" value="createExcel" onclick="GetFieldData()"/>
         
        </TD>
     
     
     
  </TR>




  <table cellpadding="0" cellspacing="0" id="dataview">
    <caption><spring:message code="query.bkqkbtable"/>
  </caption>
  

  
  // 从数据库里取出的数据显示:
    <tr>
    <xsl:for-each select="/portal/portlet/other/form/listtitle/items/item">
    <th>
      <xsl:value-of select="colnote"/>   //这是表头
    </th>
    </xsl:for-each>
    </tr>
    
    <xsl:for-each select="/portal/portlet/other/form/listdata/items/item">
    <tr>   //下面的是按查询要求显示的字段下面对应的数据;
     <td><xsl:value-of select="dwmc"/> </td>
      <td><xsl:value-of select="bks"/> </td>
   <td><xsl:value-of select="tzdbh"/> </td>
   <td><xsl:value-of select="bkrq"/> </td>
   <td><xsl:value-of select="lymc"/> </td>
   <td><xsl:value-of select="yt"/> </td>  
   <td><xsl:value-of select="dwdm"/> </td>  
    </tr>
    </xsl:for-each>  
  </table>
  </div>
  </body>
  </html>

</xsl:template>  
</xsl:stylesheet>


   那一位懂点的话,可以试一下,帮忙写一个 js函数;直接取出表头和数据;


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
78.125ms