新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国XML论坛<<     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> XML网站展示,XML源代码,XML编程示例。 本版仅接受原创、转贴、网站展示,具体的技术交流请前往各相关版块。
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XML源码及示例(仅原创和转载) 』 → 偶是菜鸟,我想在一个由xml生成的树形目录上添加checkbox,怎么添加呀? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 4062 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 偶是菜鸟,我想在一个由xml生成的树形目录上添加checkbox,怎么添加呀? 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     ecard 帅哥哟,离线,有人找我吗?魔羯座1980-1-1
      
      
      等级:大一新生
      文章:9
      积分:79
      门派:W3CHINA.ORG
      注册:2004/3/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给ecard发送一个短消息 把ecard加入好友 查看ecard的个人资料 搜索ecard在『 XML源码及示例(仅原创和转载) 』的所有贴子 引用回复这个贴子 回复这个贴子 查看ecard的博客楼主
    发贴心情 偶是菜鸟,我想在一个由xml生成的树形目录上添加checkbox,怎么添加呀?

    偶是菜鸟,我想在一个由xml生成的树形目录上添加checkbox,怎么添加呀?
    这个东西是网上下的一个示例,我想在每个接点上加一个选择框checkbox,怎么加?
    <a href="http://www.vckbase.com/code/downcode.asp?id=1629">下载例子代码</a>
    以下是tree.xml的原文:
    <?xml version="1.0" encoding="gb2312"?>
    <tree>
      <entity id="e1">
        <description>在线杂志</description>
        <image>images/book.gif</image>
        <imageOpen>images/bookOpen.gif</imageOpen>
    <checkbox>e1</checkbox>
        <contents>
          <entity id="e2">
            <description>第十二期</description>
            <image>images/book.gif</image>
            <imageOpen>images/bookOpen.gif</imageOpen>
            <onClick></onClick>
            <contents>
              <entity id="e3">
                <description>组件对象模型</description>
                <image>images/book.gif</image>
                <imageOpen>images/bookOpen.gif</imageOpen>
                <onClick></onClick>
                <contents>
                  <entity id="e4">
                    <description>OLE 编程</description>
                    <image>images/paper.gif</image>
                    <imageOpen>images/paper.gif</imageOpen>
                    <onClick></onClick>
                    <contents/>
                  </entity>
                  <entity id="e5">
                    <description>ATL编程</description>
                    <image>images/book.gif</image>
                    <imageOpen>images/bookOpen.gif</imageOpen>
                    <onClick></onClick>
               <contents>
                 <entity id="e51">
                   <description>OLE 编程</description>
                   <image>images/paper.gif</image>
                   <imageOpen>images/paper.gif</imageOpen>
                   <onClick></onClick>
                   <contents/>
                 </entity>
                 <entity id="e52">
                   <description>ATL编程</description>
                   <image>images/paper.gif</image>
                   <imageOpen>images/paper.gif</imageOpen>
                   <onClick></onClick>
                   <contents/>
                 </entity>
               </contents>
                  </entity>
                </contents>
              </entity>
              <entity id="e3">
                <description>dotNet框架</description>
                <image>images/book.gif</image>
                <imageOpen>images/bookOpen.gif</imageOpen>
                <onClick></onClick>
                <contents>
                  <entity id="e4">
                    <description>C# 编程</description>
                    <image>images/paper.gif</image>
                    <imageOpen>images/paper.gif</imageOpen>
                    <onClick></onClick>
                    <contents/>
                  </entity>
                  <entity id="e5">
                    <description>数据库编程</description>
                    <image>images/paper.gif</image>
                    <imageOpen>images/paper.gif</imageOpen>
                    <onClick></onClick>
                    <contents/>
                  </entity>
                </contents>
              </entity>
            </contents>
          </entity>
          <entity id="e2">
            <description>第十三期</description>
            <image>images/book.gif</image>
            <imageOpen>images/bookOpen.gif</imageOpen>
            <onClick></onClick>
            <contents>
              <entity id="e3">
                <description>组件对象模型</description>
                <image>images/book.gif</image>
                <imageOpen>images/bookOpen.gif</imageOpen>
                <onClick></onClick>
                <contents>
                  <entity id="e4">
                    <description>OLE 编程</description>
                    <image>images/paper.gif</image>
                    <imageOpen>images/paper.gif</imageOpen>
                    <onClick>www.vckbase.com/index.html</onClick>
                    <contents/>
                  </entity>
                  <entity id="e5">
                    <description>ATL编程</description>
                    <image>images/paper.gif</image>
                    <imageOpen>images/paper.gif</imageOpen>
                    <onClick>www.vckbase.com/index.html</onClick>
                    <contents/>
                  </entity>
                </contents>
              </entity>
              <entity id="e3">
                <description>dotNet框架</description>
                <image>images/book.gif</image>
                <imageOpen>images/bookOpen.gif</imageOpen>
                <onClick></onClick>
                <contents>
                  <entity id="e4">
                    <description>C# 编程</description>
                    <image>images/paper.gif</image>
                    <imageOpen>images/paper.gif</imageOpen>
                    <onClick></onClick>
                    <contents/>
                  </entity>
                  <entity id="e5">
                    <description>数据库编程</description>
                    <image>images/paper.gif</image>
                    <imageOpen>images/paper.gif</imageOpen>
                    <onClick></onClick>
                    <contents/>
                  </entity>
                </contents>
              </entity>
            </contents>
          </entity>
        </contents>
      </entity>
    </tree>
    tree.xsl文件的内容如下:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="javascript">
    <xsl:template match="tree">
      <xsl:apply-templates select="entity"/>
    </xsl:template>

    <xsl:template match="entity">
      <div onclick="window.event.cancelBubble = true;clickOnEntity(this);" onselectstart="return false" ondragstart="return false">
      <xsl:attribute name="image"><xsl:value-of select="image"/></xsl:attribute>
      <xsl:attribute name="imageOpen"><xsl:value-of select="imageOpen"/></xsl:attribute>
      <xsl:attribute name="open">false</xsl:attribute>
      <xsl:attribute name="id">f<xsl:value-of select="@id"/></xsl:attribute>
      <xsl:attribute name="open">false</xsl:attribute>
      <xsl:attribute name="STYLE">
        padding-left: 20px;
        cursor: hand;
        <xsl:if expr="depth(this) > 2">
          display: none;
        </xsl:if>
      </xsl:attribute>
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="middle">
              <img border="0" id="image">
                <xsl:attribute name="SRC">
                  <xsl:value-of select="image"/>
                </xsl:attribute>
              </img>
            </td>
            <td valign="middle" nowrap="true">
            <xsl:attribute name="STYLE">
              padding-left: 7px;
              font-family: Verdana;
              font-size: 11px;
              font-color: black;
            </xsl:attribute>
            <xsl:value-of select="description"/></td>
          </tr>
        </table>
      <xsl:apply-templates select="contents/entity"/>
      </div>
    </xsl:template>

    </xsl:stylesheet>
    tree.js的内容:
    function initialize() {
      var xmlDoc
      var xslDoc

      xmlDoc = new ActiveXObject(''''Microsoft.XMLDOM'''')
      xmlDoc.async = false;

      xslDoc = new ActiveXObject(''''Microsoft.XMLDOM'''')
      xslDoc.async = false;

      xmlDoc.load("tree/tree.xml")
      xslDoc.load("tree/tree.xsl")

      folderTree.innerHTML = xmlDoc.documentElement.transformNode(xslDoc)
    }

    function clickOnEntity(entity) {
      if(entity.open == "false") {
        expand(entity, true)
      }
      else {
        collapse(entity)
      }
      window.event.cancelBubble = true
    }

    function expand(entity) {
      var oImage

      oImage = entity.childNodes(0).all["image"]
      oImage.src = entity.imageOpen
      for(i=0; i < entity.childNodes.length; i++) {
        if(entity.childNodes(i).tagName == "DIV") {
          entity.childNodes(i).style.display = "block"
        }
      }
      entity.open = "true"
    }

    function collapse(entity) {
      var oImage
      var i

      oImage = entity.childNodes(0).all["image"]
      oImage.src = entity.image

      // 收缩和隐藏字节点
      for(i=0; i < entity.childNodes.length; i++) {
          if(entity.childNodes(i).tagName == "DIV") {
            if(entity.id != "folderTree") entity.childNodes(i).style.display = "none"
            collapse(entity.childNodes(i))
          }
        }
      entity.open = "false"
    }

    function expandAll(entity) {
      var oImage
      var i

      expand(entity, false)

      // 展开子节点
      for(i=0; i < entity.childNodes.length; i++) {
        if(entity.childNodes(i).tagName == "DIV") {
          expandAll(entity.childNodes(i))
        }
      }
    }      

    麻烦大家了,江湖救急呀,我等着用这个来显示一棵很大很大的树呢。


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/3/25 16:10:00
     
     GoogleAdSense魔羯座1980-1-1
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XML源码及示例(仅原创和转载) 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/3 12:51:03

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    78.125ms