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
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
297 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create animated movies for web page 18 81
Jquery Validation Messages Not Showing Up 3 20
Dynamic Dropdowns 15 32
Multiflying 2 Input Text On a Table 7 31
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

791 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