Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2004, 03:20 PM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default onClick as xsl attribute?

I cut the follwoing snippet of code from an xsl that I use to format test data for presentation. The second line of code declares the onclick method as an xsl attribute. The sixth line of code includes the declaration of the onclick inline with the html. What's the difference? I eventually want my user to click the href tag and use the ID associated with that row (in this case the name of the test data) to be sent to a javascript method that will set a parameter in the xsl and will allow me to access a specific node in the xml tree. Is that logical?

    <TR id="trnode">
    <xsl:attribute name="onclick">selectRow(this)</xsl:attribute>
    <xsl:attribute name="ondblclick">selectRow(this);selectTestCurren tRow()</xsl:attribute>
    <TD id="idCol" width="200">
        <a href="{./ID/@value}testreport.htm" onClick="alert('Hello from JavaScript!')"><xsl:value-of select="./ID"/></a>
    </TD>

 
Old September 10th, 2004, 02:36 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Regarding your XSLT there is no difference in your case between constructing an attribute using the xsl:atribute element and writing it to an element literal as you have done with the 'a' element. The first method gives you more control over namespaces and dynamic control of the attribute name but you do not need that.

As to your JavaScript I'm not sure what you want but what you have looks a little odd. When you click on the 'a' element you will receive an alert and the selectRow will be fired passing the 'TR' object as its only argument. Unless you return false from this method then the href in the 'a' element will also be navigated to.



--

Joe (Co-author Beginning XML, 3rd edition)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excluding attribute from xsl:coy-of ricksj XSLT 1 October 6th, 2008 04:56 PM
escaping of characters in xsl:attribute pramod Classic ASP XML 1 September 12th, 2008 09:11 AM
trouble setting the onclick attribute cjwahlen Javascript How-To 0 May 18th, 2007 01:05 PM
<xsl:attribute> vs {} berna_isct XSLT 1 April 6th, 2006 03:30 PM
XSL Attribute ID jonty XSLT 1 March 28th, 2006 03:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.