Solved

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

Posted on 2009-05-17
6
295 Views
Last Modified: 2013-11-18
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

0
Comment
Question by:mkarthik415
  • 4
  • 2
6 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24407526
                   <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
0
 

Author Comment

by:mkarthik415
ID: 24407712
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.

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24409536
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


0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:mkarthik415
ID: 24417756
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.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24418611
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
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 24420130
have you tried checking what
this.href or this.class is?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Polygon I google maps 1 16
How can I get this SlideToggle to behave? 6 19
bootstrap footer centering and expand problems 7 30
Jquery get each value 2 17
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now