Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 9th, 2004, 03:20 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
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>

Reply With Quote
  #2 (permalink)  
Old September 10th, 2004, 02:36 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:13 PM.


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