Link to home
Start Free TrialLog in
Avatar of mkarthik415
mkarthik415

asked on

how to call javascript with more than one parameter in xsl file when one of the parameter is 'this' keyword

I am trying to call getControls function from xsl file, which has three parameters, two are xml tags and third one 'this' keyword.

I think I have called the function wrongly from xsl file.

Please help

Thank you.
<?xml version="1.0" ?> 
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.0"> 
<channel> 
          <title>Assurance</title> 
          <link>gmail.com</link> 
           <description>ess Alert</description> 
             <item> 
                           <userID>_b</userID> 
               <item>
<channel>
 
above is the xml file
 
 
-------------------------------------------------------------
<a class="buttonGo" href="#">
	   <xsl:attribute name="onclick">
                    <xsl:text>javascript:getControls('</xsl:text>
	    <xsl:value-of select="link"/>
                    <xsl:text>','</xsl:text>
	     <xsl:value-of select="title"/>
                    <xsl:text>','</xsl:text>
	    <xsl:value-of select="this"/>
	    <xsl:text>');</xsl:text>
	    </xsl:attribute></a>
 
I am using this function  in the html how can i pass one more parameter to the above function like' title' from the xml.
 
abve is the xsl code
 
 
 
 
------------------------------------------
function getControls(link,title,obj)
{
 
}
code in the html

Open in new window

Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

                   <xsl:text>','</xsl:text>
          <xsl:value-of select="this"/>
          <xsl:text>');</xsl:text>

should become
                    <xsl:text>','this');</xsl:text>

this is not an element, so no need for value-of
Avatar of mkarthik415
mkarthik415

ASKER

after replacing with this
<xsl:text>','this');</xsl:text>
I am not able to access the object in the getControls() function.

When I am put alert to check obj, I am getting this in alert box. what I need is the object of the anchour tag.

function getControls(link,title,obj)
{
 alert(obj);
}


Thank you.

Please, carefully check what we are doing

                    <xsl:text>','</xsl:text>
          <xsl:value-of select="this"/>
          <xsl:text>');</xsl:text>

Passes the string content of the element <this> as a string in the parameter field

With my suggestion, you still have quotes, so you pass the string "this" as a parameter
                  <xsl:text>','this');</xsl:text>

if you remove the quotes, you would be passing the object
                  <xsl:text>',this);</xsl:text>

I hope you understand the difference between all of them


I am still not able to get the object, I am getting an error as "null or not a object". I should be able to get the object, because in my senario I have to go to the parent element with the help of this object.

Please help.

Thank you.
well, you now have access to the "this" object, whatever that is,
but I think you will need something in terms of
"this.form" or similar
why do you need the object in the function? It is kind of tricky
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial