xsl-list
[Top] [All Lists]

How To Call XSL Template With Parameter From OnClick Event

2003-11-04 22:09:49
I need to be able to allow users to click on a link from a summary page and open up a detailed window based on what was chosen. How do I call an XSL template with a parameter from an OnClick event?

Is this possible with or without javascript? I have tried many things with no success.

In its simplest form, here's what I'm trying to do.  Thanks!

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml:stylesheet type="text/xsl" href="test.xsl"?>
<INVENTORY>
    <ITEM>
         <ITEM_NO>1</ITEM_NO>
         <SUMMARY_INFO>Summary Info</SUMMARY_INFO>
         <DETAILS>
              <DETAIL_INFO>Detail Info</DETAIL_INFO>
         </DETAILS>
    </ITEM>
</INVENTORY>

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output method="html" indent="no"/>
    <xsl:template match="/">
         <html>
              <head>
                   <script language="javascript" type="text/javascript">
                   <!-- //
                        function callDetail(item_no)
                        {
                             <xsl:call-template name="detail">
                                  <xsl:with-param name="item_input">
                                       <xsl:value-of select="$item_no"/>
                                  </xsl:with-param>
                             </xsl:call-template>
                        }
                   // End -->
                   </script>
              </head>
              <body leftmargin="0" marginwidth="0" topmargin="0">
                   <xsl:variable name="item_no" select="'1'"/>
                   <a href="#" onclick="callDetail($item_no)">
&#160;<xsl:value-of select="INVENTORY/ITEM[ITEM_NO=$item_no]/SUMMARY_INFO"/>
                   </a>
              </body>
         </html>
    </xsl:template>

    <xsl:template name="detail">
         <xsl:param name="item_input"/>
         <html>
              <head>
              </head>
              <body leftmargin="0" marginwidth="0" topmargin="0">
<xsl:copy-of select="INVENTORY/ITEM[ITEM_NO=item_input]/DETAIL_INFO"/>
              </body>
         </html>
    </xsl:template>
</xsl:stylesheet>




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