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 © 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