Re: [xsl] newbie question concerning javascript and xsl.

Subject: Re: [xsl] newbie question concerning javascript and xsl.
From: Emmanouil Batsis <Emmanouil.Batsis@xxxxxxxxxxx>
Date: Wed, 02 Mar 2005 18:14:37 +0200
Emmanouil Batsis wrote:


Not sure what you are trying to do but i think


<td class="community"
  onclick="submit_channel(this.data)">
  <xsl:value-of select="EXTENSION"/>
</td>


Grr, of course this will not work as "data" is a text node property. You'll need to do something like

onclick="getValue(this)">

where getValue is
// untested, just typing directly
function getValue(oElem){
  var s = "";
  var nodes = oElem.childNodes;
  for(int i=0;i<nodes.length;i++){
     // nodeType only gives ints in IE :-(
     if(nodes[i].data) s += nodes[i].data;
  };
 submit_channel(s);
};


Manos



or <td class="community" onclick="submit_channel('{EXTENSION}')"> <xsl:value-of select="EXTENSION"/> </td>



will work fine. The first delegates the responsibility to JS, the latter handles it in the transformation.

hth,

MAnos


Lior Kesos wrote:


I have a "classic" xml xsl and javascript environment in which all of
the elements are on different files.
My index.html loads the xml and xsl succssfully and renders a table
which you can see below.

<xsl:for-each select="CHANNEL[SERVER = 'db2srv1']">
       <xsl:sort select="name"/>
       <tr>
       <xsl:if test="META = 'enterprise'">
         <td class="enterprise"
onclick="submit_channel(this.innerHTML)"><xsl:value-of
select="EXTENSION"/></td>
       </xsl:if>
       <xsl:if  test="META = 'community'">
         <td class="community"
onclick="submit_channel(this.innerHTML)"><xsl:value-of
select="EXTENSION"/></td>
       </xsl:if>
       </tr>
       </xsl:for-each>

I know that the this.innerHTML is wrong but I can't figure out how to
pass the EXTENSION parameter to the javascript.

The closest I got to was if I put submit_channel({.}) which I saw in
some sniplet.
I have been trying to read this until solution  but after 2 days of
googling and trying different approaches I'm consulting with the
pros...

any help will be appriciated.
Lior.

Current Thread