[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL And Checkboxes with javascript reference problem

Subject: XSL And Checkboxes with javascript reference problem
From: "Frans Herbst" <fherbst@xxxxxxxxxxxxx>
Date: Tue, 8 Oct 2002 22:07:51 +0200
clickonentity
Hi All,

I have a problem with  the following:
I have a stylesheet showing data from an xml source:

<?xml version="1.0"?>
<rs>
  <entity id="e1" all="y" descr="All Details" n="1" sel="true">
    <contents>
      <entity id="e2" cb="y" descr="Branch - 1">
        <contents>
          <entity id="e3" cc="y" descr="Sub Branch a"/>
          <entity id="e4" cc="y" descr="Sub Branch b"/>
        </contents>
      </entity>
      <entity id="e5" cb="y" descr="Branch - 2">
        <contents>
          <entity id="e6" cc="y" descr="Sub Branch a"/>
          <entity id="e7" cc="y" descr="Sub Branch b"/>
        </contents>
      </entity>

    </contents>
  </entity>
</rs>

The xsl Stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"
language="JavaScript">

<xsl:template match="rs">
    <xsl:apply-templates select="entity"/>
</xsl:template>

<xsl:template match="entity">
  <div onclick="window.event.cancelBubble =
true;clickOnEntity(this);selectitem(this)" onselectstart="return false"
ondragstart="return false">
  <xsl:if match=".[@all='y']">
    <xsl:attribute name="image">images/book.gif</xsl:attribute>
    <xsl:attribute name="imageopen">images/bookopen.gif</xsl:attribute>
  </xsl:if>

  <xsl:if match=".[@cb='y']">
    <xsl:attribute name="image">images/book.gif</xsl:attribute>
    <xsl:attribute name="imageopen">images/bookopen.gif</xsl:attribute>
  </xsl:if>

  <xsl:if match=".[@cc='y']">
    <xsl:attribute name="image">images/space.gif</xsl:attribute>
    <xsl:attribute name="imageopen">images/space.gif</xsl:attribute>
  </xsl:if>

  <xsl:attribute name="open">false</xsl:attribute>
  <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
  <xsl:attribute name="name"><xsl:value-of select="@descr"/></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" nowrap="true">
          <img border="0" id="image">
            <xsl:attribute name="SRC">
              <xsl:if match=".[@all='y']">
                 images/book.gif
              </xsl:if>
              <xsl:if match=".[@cb='y']">
                 images/book.gif
              </xsl:if>
              <xsl:if match=".[@cc='y']">
                 images/space.gif
              </xsl:if>
            </xsl:attribute>
          </img>
        </td>

        <td valign="middle" nowrap="true" id="branchboxid">
          <input type="checkbox" name="branchbox" checked="true">
            <xsl:attribute name="checked">checked</xsl:attribute>
          </input>
        </td>

        <td valign="middle" nowrap="true">
        <xsl:attribute name="STYLE">
          padding-left: 7px;
          font-family: Verdana;
          font-size: 11px;
          font-color: red;
        </xsl:attribute>
        <font class="samespace"><xsl:value-of select="@descr"/></font></td>
      </tr>
    </table>
  <xsl:apply-templates select="contents/entity"/>
  </div>
</xsl:template>


</xsl:stylesheet>


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/ROLUP_13200210031612.XML")

  xslDoc.load("tree/rollup.xsl")

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


function clickOnEntity(entity) {

  alert(entity.checked);

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

With this in an asp page the user gets a drilldown list. The problem is that
I cannot reference to the checkbox.
clickOnEntity(this) where (this) does not contain any information about the
checkbox - I need to check
in this javascript if the entity checkbox is selected or not.
I tried adding a attibute at the top including
  <xsl:attribute name="checked">false</xsl:attribute>
but then the value returned is always false.

Hope somebody can help, I have been searching for three day's to resolve
this problem.
What I want to achieve is that once a user clicks on the first checkbox, all
the other checkboxes must be selected or deselected according to the first
level, then if the first level is deselected, the second level can be
activated with it's children.

Regards
Frans Herbst


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.