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
294 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to count occurrences of each item in an array.

760 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

20 Experts available now in Live!

Get 1:1 Help Now