Results 1 to 2 of 2

Thread: Call javascript function with parameter using XSLT

  1. #1
    Join Date
    Nov 2006
    Posts
    5

    Call javascript function with parameter using XSLT

    I'm having trouble getting my head around XSLT. I am creating an html table and filling it with the xml data using jascript.

    i have it basically working but the next thing I want to do is call a javascript function and pass it one of the xml values as a parameter.

    I'm trying it with a very simple class at the moment to see if I can get it to work; this is my code.

    Function:
    Code:
    function loadMsg(mId)
    {
    alert(mId);
    }
    XSLT (snippet):
    Code:
    <tr class="msgListItem" onmouseover="style.backgroundColor='#ff0000';" 
    onmouseout="style.backgroundColor='#ffffff';" 
    onclick='loadMsg(<xsl:value-of select="mailid"/>);'>
    I know everything works as expected when I do:
    Code:
    <tr class="msgListItem" onmouseover="style.backgroundColor='#ff0000';" 
    onmouseout="style.backgroundColor='#ffffff';" 
    onclick='loadMsg("some text");'>


    anyone have any ideas?

    thanks

  2. #2
    Join Date
    May 2009
    Location
    England
    Posts
    165
    Hi beezleboss,

    I'm not an expert on this but shouldn't you put the XSL value in some kind of quotes? It looks to me like you're telling javascript that <xsl:value-of select="mailid"/> is a variable.

    Just my passing comment ... hope it works out for you.

    Regards,

    David
    David McLeary
    Emerging Innovations
    Website Development, Training and Consultancy

Similar Threads

  1. call to non-member function - need help!!
    By appleifreak in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 06 Jun 2009, 01:51 AM
  2. calling javascript function using array values
    By flann in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 12 Sep 2007, 10:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •