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 March 31st, 2015, 04:56 AM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to pass xsl:varialbe to javascript function

How to pass the variable value to javascript which is defined inside xsl

XSL file:
<xsl:variable name="customKey">customValue</xsl:variable>
<a href="javascript:;" onclick="view(?)"> View Link </a>

From the above xsl file how to pass my variable value in place of ?
 
Old March 31st, 2015, 05:05 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

There is no interaction between XSLT and Javascript in the result HTML of your XSLT. If you want to construct an HTML element with an onclick handler then you simply need to construct what you would normally write, so assuming you would want a HTML element
Code:
<a href="#" onclick="view('customValue')">View Link</a>
to construct that code with XSLT you can use
Code:
<a href="#" onclick="view('{$customKey}')">View Link</a>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 31st, 2015, 05:10 AM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the prompt response. It works.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: How to get javascript function return SELECT value in xsl ojoker XSLT 5 May 24th, 2011 11:52 AM
Executing a JavaScript Function from XSL IronStar XSLT 5 July 8th, 2010 07:49 PM
Pass PHP variable to JavaScript function jpindi Javascript How-To 2 September 9th, 2009 11:41 AM
xsl:function pass param to attribute of xsl:instruction bonekrusher XSLT 4 March 31st, 2009 09:06 AM
how to pass javascript variable to xsl eruditionist XSLT 4 September 8th, 2008 08:37 AM





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