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

pass <id> element value to a javascript function.

Subject: pass <id> element value to a javascript function.
From: "Chen Wang" <wangchen01@xxxxxxxxx>
Date: Sun, 9 Sep 2001 03:43:02 -0700
javascript pass id
Here is the code in xsl:
<script language="javascript">

 function WM_toggle(id){

   if (document.all){
     if(document.all[id].style.display == 'none'){
       document.all[id].style.display = 'block';
     } else {
      document.all[id].style.display = 'none';
  } else if (document.getElementById){
    if(document.getElementById(id).style.display == 'none'){
      document.getElementById(id).style.display = 'block';
    } else {
      document.getElementById(id).style.display = 'none';
<!--menu part-->
<xsl:for-each select="placetogo/urbanspace">
<a href="#" onclick="WM_toggle('{cityid}'); return false"><xsl:value-of
select="placename"/></a> <br />
<!--content part-->
 <xsl:for-each select="placetogo/urbanspace">
    <p align="center" class="main" style="display: none"><xsl:attribute
name="id"><xsl:value-of select="cityid"/></xsl:attribute>

   <xsl:value-of select="placename"/> <br />
   <img><xsl:attribute name="src"><xsl:value-of
select="photo/@img"/></xsl:attribute></img> <br />
   <xsl:value-of select="country"/>


In xml, it looks like this:
<?xml version="1.0" ?>

    <photo img="barcelona.jpg" />
    <description>Barcelona is a city where architecture and urbanism are

    <placename>Hong Kong</placename>
    <photo img="hong_kong.jpg" />
    <description>Hong Kong is one of the greatest maritime cities there has
ever been---noisy, boisterous, cluttered, and vibrant. </description>

So, in the menu part, the code will read in the city name from xml and the
city name is a link which when it is clicked it will toggle the
correspondent paragraph under content part.  I assume that
WM_toggle('{cityid}') will read in 'ba' and 'hk' for bacelona, and hong kong
link respectively, but the code does not work.  When I clicked the link, it
has error like: document.all[...].style is null or not an object.  By the
way, I am using IE6 for these code. Please help me.


Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

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

Current Thread


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.
First Name
Last Name
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.