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
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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 if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

749 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