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 October 14th, 2011, 03:19 PM
Registered User
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing an XSLT variable to a javascript function in a link...

Maybe I am going about this all wrong, but I want to have a table row using xsl that when clicked will display a diff table in a new window. So I have this script written into the template that matches the root...
Code:
<script type="text/javascript">
			function displayTable(table){
				myWindow = window.open()
				myWindow.document.write(table)
				myWindow.focus()
			}
		</script>
I then make the table and place it in a variable like this....
Code:
<xsl:variable name="propTable">
			<table>
			<xsl:for-each select="property">
				<xsl:sort select="@name"/>
				<xsl:apply-templates select="."/>
			</xsl:for-each>
			</table>
		</xsl:variable>
This is how I am making the table row...
Code:
<tr onclick="displayTable('hi')">
Which pops up the window like i expect it to and displays the word hi, which is what I expect. I need a way to be able to drop the variable propTable as a parameter for displayTable. Everything I try I keep coming back to the fact that I can't put a < in a parameter. Any thoughts?
 
Old October 14th, 2011, 03:53 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Assuming what you want to display is in an element called 'element' then this would work:

Code:
<xsl:attribute name="onclick">displayTable('<xsl:value-of select="element"/>')</xsl:attribute>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
passing javascript variable in xsl:value-of select eruditionist XSLT 2 September 19th, 2008 05:23 PM
passing variable to function Boszky Pro PHP 2 December 15th, 2005 03:01 AM
passing variable to function in innerHTML crmpicco Javascript How-To 5 October 19th, 2005 10:25 AM
Passing a variable into the id() function EstherMStrom XSLT 5 January 19th, 2005 02:32 PM
Passing a parameter into the XSLT thru a link Liska XSLT 0 July 16th, 2004 08:19 PM





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