I am working on a data view web part. I am using Java script for some of my functioning and having trouble with calling javascript function with more than one arguments while single argument function is working fine.

When i used this single argument function, it worked fine:

    <script type="text/javascript">
    function PrintElement(loopPosition)
    PrintElement(<xsl:value-of select="$pos"/>);                    

Later on, i tried to add one more argument but it is not calling the javascript function and page is giving error on the line where function is being called.

I tried the following but no luck:

PrintElement(<xsl:value-of select="$pos"/>,<xsl:value-of select="$FPageName"/>);
PrintElement(<xsl:value-of select="$pos"/>+","+<xsl:value-of select="$FPageName"/>);
PrintElement("'"+<xsl:value-of select="$pos"/>+"'","'"+<xsl:value-of select="$FPageName"+"'"/>);
PrintElement("'"+<xsl:value-of select="$pos"/>+"','"+<xsl:value-of select="$FPageName"+"'"/>);

First and Second statementdoes not call the function and third throws an error.

Could someone please help me with the exact sysntax and elaborate a bit.

  • PrintElement("'"+<xsl:value-of select="$pos"/>+"','"+<xsl:value-of select="$FPageName" />"'"); should work Jun 3, 2013 at 9:44
  • It should but it doesn't
    – Mohit
    Jun 3, 2013 at 11:43

2 Answers 2


If you want to pass two arguments to a Javascript function, then that function needs to be defined to have two arguments. If it is defined to take only one argument, then, of course it will error.

So, change your Javascript function to accept and process a second argument along the lines of this:

<script type="text/javascript">
    function PrintElement(loopPosition, PageName)
  • My mistake, I didnt explained properly. Its already there.
    – Mohit
    Jun 3, 2013 at 11:44

Finally, I made it work. It goes like this:

PrintElement('<xsl:value-of select="$pos"/>','<xsl:value-of select="$FPageName"/>');

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.