Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Call a function defined in =?UTF-8?B?4oCcbXN4c2w6c2NyaXB04oCd?= =?UTF-8?B?IGJsb2NrIGZyb20g4oCcb25jbGlja+KAnQ==?=

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 4/3/2008 5:54:00 PM

Eugene wrote:

> How can I pass a variable or a parameter to this function?
> 
> i. e.:
> 
> <xsl:param name="sampleParam" select="@Sample" />
> ...
>    <td onclick="onClickHandler( $sampleParam );">
>      ...
>    </td>
>    <script type="text/javascript">
> 
>    function onClickHandler (sampleParam ) {
>      ...
>    }
>    </script>

You have to be aware that your XSLT stylesheet constructs a HTML 
document where in that case the HTML document has some script embedded. 
You can't pass parameters in the XSLT stylesheet to the script functions 
as the XSLT transformation is executed first and has as its result the 
HTML document with the script and the script is executed later. What you 
can do however is construct JavaScript code where you use values of XSLT 
parameters or values.
So you can use attribute value templates for instance to do e.g.
   <td onclick="onClickHandler({$sampleParam});">
but you need to make sure that you construct syntactically correct 
JavaScript code. Thus the above will work for instance if $sampleParam 
has a number value (e.g. 2.5) as that results in the JavaScript code
    onClickHandler(2.5);
If the $sampleParam is a string however then you need to make sure you 
construct a JavaScript string literal e.g.
   <td onclick="onClickHandler('{$sampleParam}');">
That will work as long as $sampleParam does not contain a single quote.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent