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 '13 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 '13 at 6:47

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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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