0

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)
     {
        alert(title);
     }

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

2
  • How does it render? You might have to use <xsl:attribute /> to output the onclick bit. Commented 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 Commented Sep 19, 2013 at 6:47

1 Answer 1

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.