473,809 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to passed an xsl parameter to a javascript function inside an xsl styelsheet.

7 New Member
Hi:

I am having problem passing an xsl param variable as a parameter to a javascript function inside an
xsl styelsheet.

Here is my xsl stylesheet.

<xsl:param name="numberOfR ecordsFromDatab ase" select="search-result/rec-num" />
<xsl:template name="Body">
<body bgcolor="#FFFFF F" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0 "
onLoad="cloneHe ader();window.p arent.shrinkIFr ame(<xsl:value-of select='$number OfRecordsFromDa tabase'/>);"
onresize="clone HeaderResize(); window.parent.s hrinkIFrame(<xs l:value-of select='$number OfRecordsFromDa tabase'/>);">
</body>
</xsl:template>
I am trying to pass a variable called numberOfRecords FromDatabase to
a javascript function called window.parent.s hrinkIFrame(<xs l:value-of select='$number OfRecordsFromDa tabase'/>).


Is this possible?
If not, is there a way to do this.
Any hint would be greatly appreciated.

Yours,

Frustrated.
Jun 22 '07 #1
1 2383
Dököll
2,364 Recognized Expert Top Contributor
Hi:

I am having problem passing an xsl param variable as a parameter to a javascript function inside an
xsl styelsheet.

Here is my xsl stylesheet.



I am trying to pass a variable called numberOfRecords FromDatabase to
a javascript function called window.parent.s hrinkIFrame(<xs l:value-of select='$number OfRecordsFromDa tabase'/>).


Is this possible?
If not, is there a way to do this.
Any hint would be greatly appreciated.

Yours,

Frustrated.
Hello, jadeite100!

I have not toyed around with XML through JavaScript. I do have an option for the time being which can be viewed in HTML. You can then embed the HTML in your JavaScript, if you'd like to go this route:

[HTML] XML

<?xml version="1.0"?>
<!-- File Name: App_Author.xml -->
<App_Author_Mat ch>
<The_Author>
<Type>Hard cover</Type>
<My_Authors>Sil verstein</My_Authors>

<Local>The Giving Tree</Local>
<Option_Bound>B ook Shelf # 1 - Home School Room</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>Sil verstein</My_Authors>

<Local>Fallin g Up</Local>
<Option_Bound>B ook Shelf - Bedroom</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>Sil verstein</My_Authors>

<Local>Where the Sidewalk Ends</Local>
<Option_Bound>B ook Shelf # 1 - Home School Room</Option_Bound>
</The_Author>

<The_Author>
<Type>Hard cover</Type>
<My_Authors>Sil verstein</My_Authors>

<Local>The Missing Piece</Local>
<Option_Bound>B ook Shelf # 1 - Home School Room</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Wacky Wednesday</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Green Eggs and Ham</Local>
<Option_Bound>B ook Shelf - Bedroom</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>The Spooky Old Tree</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Go, Dog. Go!</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Hand, Hand, fingers, thumb</Local>
<Option_Bound>B ook Shelf - Bedroom</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Mr. Brown can Moo! Can You?</Local>
<Option_Bound>B ook Shelf - Bedroom</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Maybe You Should Fly a Jet</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>oh, the THINKS you can think!</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Ten Apples Up On Top!</Local>
<Option_Bound>B ook Shelf - Bedroom</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Becasu e a Little Bug went Ka-CHOO!</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>Bears on Wheels</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>The FOOT Book</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>

<The_Author>
<Type>Hard cover</Type>
<My_Authors>D r. Seuss</My_Authors>

<Local>The Cat In The Hat</Local>
<Option_Bound>B ook Shelf # 2 - Home School Room</Option_Bound>
</The_Author>

<The_Author>
<Type>Hard cover</Type>
<My_Authors>Num eroff</My_Authors>

<Local>If You Give a Pig a Party</Local>
<Option_Bound>B ook Shelf - Bedroom</Option_Bound>
</The_Author>



<The_Author>
<Type>Hard cover</Type>
<My_Authors>Num eroff</My_Authors>

<Local>If You Give a Moose a Muffin</Local>
<Option_Bound>B ook Shelf - Bedroom</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>Num eroff</My_Authors>

<Local>If You Give A Mouse A Cookie</Local>
<Option_Bound>B ook Shelf # 1 - Home School Room</Option_Bound>
</The_Author>


<The_Author>
<Type>Hard cover</Type>
<My_Authors>Num eroff</My_Authors>

<Local>If You Give A Pig a Pancake</Local>
<Option_Bound>B ook Shelf # 1 - Home School Room</Option_Bound>
</The_Author>

<The_Author>
<Type>Hard cover</Type>
<My_Authors>Num eroff</My_Authors>

<Local>If You Take A Mouse to School</Local>
<Option_Bound>B ook Shelf # 1 - Home School Room</Option_Bound>
</The_Author>
</App_Author_Matc h>

[/HTML]


You will need this code to see above files through link work:

[HTML]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sequio a - Snapshots, Books, and Things - Browse My Favourite Authors</title>
<link rel="stylesheet " type="text/css" href="style.css " />
</head>
<body bgcolor="linen" >
<xml id="dsoAUTHOR_U NITS" src="App_Author .xml"></xml>
<p align="center">

<p></p>
<p style="font-size:24px; color: red; font-weight:900">Bro wse My Favourite Authors</p>
<p style="font-size:18px; color: orange; font-weight:100">Dr. Seuss, Numeroff, Silverstein: <input type="text" id="searchtext " size="20" onKeyPress="key Pressed()">&nbs p;
<button onClick="findAu thors()">search </button>
</p>


<hr size="5" color="#cccccc"/>
<div id="searchresul t">
<p style="font-size:18px; color: darkgreen; font-weight:100">Res ults:
</div>
<script type="text/javascript">
<!--hide from old browsers
function keyPressed(k) {
var hitEnter=event. keyCode
if (hitEnter==13) findAuthors()
}

function findAuthors() {
searchstring = searchtext.valu e.toUpperCase()
if (searchstring== "") {
searchresult.in nerHTML = "<b>&Please enter author name</b>"
return
}
dsoAUTHOR_UNITS .recordset.move First()
var outputresult=""
while (!dsoAUTHOR_UNI TS.recordset.EO F) {
namestring = dsoAUTHOR_UNITS .recordset("My_ Authors").value
if (namestring.toU pperCase().inde xOf(searchstrin g)>=0)
outputresult += "<b>" + dsoAUTHOR_UNITS .recordset("My_ Authors")+"</b> ("+dsoAUTHOR_UN ITS.recordset(" Type")+")</p>"
+ "<p style='margin-left:25px'><b>B ook Title: </b>"+dsoAUTHOR_U NITS.recordset( "Local")+"</p>"
+ "<p style='margin-left:25px'><b>B ook Location: </b>"
+ dsoAUTHOR_UNITS .recordset("Opt ion_Bound") +"<br /></p>"
dsoAUTHOR_UNITS .recordset.move Next()
}
if (outputresult== "")
searchresult.in nerHTML = "I apologize, author name selected is currently unavailable"
else
searchresult.in nerHTML = outputresult
}
//-->
</script>

<hr size="5" color="#cccccc" />

<center>
<br>
<a href="toy_type. html">Browse My Cars</a> || <a href="Num_Toy_S earch.html">Sea rch My Favourite Authors</a>
</center>
<p>
<b><CENTER>
<FONT FACE="Arial" SIZE="-2" color="blue">
Copyright &copy; 2006-2008 For more information about my snapshots, books and things,<br> please contact me: <a href="mailto:XX XXXXXXX@yahoo.c om"><FONT FACE="Arial" SIZE="-2" color="darkpurp le"><b>XXXXXX@y ahoo.com</a></b></font><br> All rights reserved.
<br></CENTER>
</p>
</FONT></b>
</body>
</html>
[/HTML]

[HTML] CSS (Cascading Style Sheet)

body {margin: 8pt}

a {text-decoration: none;
color: blue}

p {font-family: Verdana, Garamond;
font-size: 11pt}

table {font-family: Verdana, Garamond;
font-size: 11pt}

th {color: white;
background-color: blue;
font-size: 11pt;
text-align: left}

caption {color: blue;
font-style: italic}

[/HTML]

This was a project I worked on for my son. Please write if you need additional help.

If you are not satisfied with this version, see an example that deals with both XML and XSL though here:

http://www.thescripts.com/forum/thread662186.html
What you will need are:

(1) XML called App_Author.xml (add first code in there)
(2) HTML called Num_Toy_Search. html (add second code in there)
(3) CSS named style.css (add third code in there)

Will keep looking re: JavaScript for you, alright...but I believe this'll do the trick for ya:-)

Dököll
Jun 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
15929
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script type="text/javascript"> window.location = "http://www.someserver.com/somePage.html"; </script>
4
5212
by: Steve Neill | last post by:
Here's an interesting problem... I have 2 functions, aFunc() and bFunc(). I call aFunc() passing a call to bFunc() as a parameter. Function aFunc() executes bFunc(). Function bFunc() lists the parameter values passed to it. OK, here's the twist... I want to add some parameters to bFunc() from inside aFunc(). Can that be done?
5
1230
by: lkrubner | last post by:
Is it true that Javascript has no clone() method, to pass an object by copy of value instead of reference? If I have an object and want to make an array out of all of its instance variables, I can loop through it and pass its values to a new array, and the class instances will be passed by copy and not by reference?
7
2003
by: Ralph Flaugher | last post by:
In C# objects are passed in functions by reference. Is there a way like in C++ to declare that the function does not alter the passed object? Something like: Foo(const Byte someThing) { } -- Ralph Flaugher
10
2518
by: Sean Dockery | last post by:
I have the following HTML file that I've been using for testing... <html> <head> <script type="text/javascript"> <!-- function handleWindowLoad() { var items = ; for (var i = 0; i < 11; i++) { items = "item" + (i + 1);
2
3826
by: Damon | last post by:
Help! Need this fixed ASAP. I have a GridView/DetailsView master/details form set up, with both bound to separate ObjectDataSource objects. Both the GridView and the DetailsView have a DataKeyNames parameter of "UserCompany, BillableCompany". The DetailsView has control parameters for its select method pointing to these two keys on the GridView. But the select method function receives two copies of the UserCompany field! The...
10
1819
by: ypjofficial | last post by:
Hello All, since the programs' stack is shared among all the function inside the program, I was just doing some R&D to see whether the same stack space is used for the variables inside the different functions are not. below is my code //program start void fun1() {int i;
29
2374
by: Vasileios Zografos | last post by:
Hi everyone, I need to build a function to plug it in a program (that I didnt make or can change) that should be called something like this: float someFunction(float x) { ...
4
3218
by: Nathan Baker | last post by:
I have a JavaScript environment using IActiveScript and friends (via COM interop). At one point, the JavaScript passes me a function as a parameter to an object that has been inserted into the JavaScript using AddNamedItem. When I look at this object and ask it for its type, it says it is a System.__ComObject. What I want to do is invoke this function in the environment that I have using the engine I have instantiated. Is there a way to...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.