I have added an icon before the image title in asset library. I want to pass the name of the current logged in user and the image title in the JavaScript function to add it in other custom list.

My code for passing the variable:

<xsl:variable name="ImageTitle" select="$thisNode/@Title"/>
<a href="#" onclick="myfunction({$ImageTitle})"> <img src="/add.png" alt="aa" height="10" widht="10"/></a>

JavaScript function:

         function myfunction(title)

but I am not getting any alert message displaying the title of the image.
What am I missing?

  • How does it render? You might have to use <xsl:attribute /> to output the onclick bit.
    – James Love
    Sep 19, 2013 at 6:41
  • Can you please suggest how to include the <xsl:attribute> in my code as I am beginner in sharepoint development. @JamesLove
    – users1100
    Sep 19, 2013 at 6:47

1 Answer 1


Most likely you're missing quotes. Instead of myfunction({$ImageTitle}) it should be myfunction('{$ImageTitle}').

Corrected code:

<xsl:variable name="ImageTitle" select="$thisNode/@Title"/>
<a href="#" onclick="myfunction('{$ImageTitle}')"> <img src="/add.png" alt="aa" height="10" widht="10"/></a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.