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 June 15th, 2006, 06:59 PM
Registered User
 
Join Date: Jun 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in passing xslt value to a javascript !

Hi,

 I'm facing a problem is passing xslt value to a javascript. I'm capturing the value of PromotionCode in a variable and then passing it to the javascript funtion.But the value is not getting passed though its getting printed properly as a text.


<xsl:for-each select="ns0:ShowPromotion/ns0:DataArea/ns0:Promotion">
     <tr bgcolor="#FFFFFF">
    <td class="tablecontent" align="center">
       <xsl:variable name="PromoCode">
         <xsl:value-of select="ns0:PromotionHeader/ns0:PromotionCode"/>
       </xsl:variable>
       <a href="javascript:call_action_soa('goPreviewSOASear ch.do','{PromoCode}','{PromoType}' )">
        <xsl:value-of select="ns0:PromotionHeader/ns0:PromotionCode"/>
       </a>
    </td>
    </tr>
</xsl:for-each>

I'll appreciate if anyone can help me out on this,also,is there any other way to do this ?

Thanks

 
Old June 15th, 2006, 11:10 PM
Registered User
 
Join Date: Jun 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Got the solution,used ,

<a href="javascript:call_action_soa('goPreviewSOASear ch.do',{$PromoCode},{$PromoType})">

$ did the trick




 
Old June 16th, 2006, 03:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I think you want $PromoCode rather than just PromoCode.

Also, don't do

<xsl:variable name="x">
  <xsl:value-of select="y"/>
</xsl:variable>

which creates a result tree fragment, when you only want a string. Instead do

<xsl:variable name="x" select="y"/>

I saw one stylesheet recently that ran 5 times faster after making this change - and why write 3 lines of code where 1 will do?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing parameter from javascript to xslt !! suersh79 XSLT 3 November 17th, 2006 03:08 AM
XSLT problem w/ creating JavaScript (FCKeditor) dornad XSLT 0 June 27th, 2006 03:53 PM
Problem in passing parameter to xslt template uttamgarg XSLT 0 April 20th, 2006 09:53 AM
passing param to XSLT Dangerous Dave XSLT 0 April 30th, 2004 07:46 PM





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