|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
XML and Javascript Variables
I have an XSL file that displays the info from my XML document. In the XSL i have some Javascript code that takes a variable out of the URL and saves it to a variable airportCode.
Is there anyway to assign the javascript variable airportCode fo the XSL paramter airportID? Thanks! - Eric ------------------------------------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl aram name="airportID"/><head> <script language="Javascript"> twdlength = window.location.search.length urlData = window.location.search.substring(13,twdlength); airportCode = "'"+ urlData + "'"; document.write("Airport Code = " + airportCode); </script> </head> <html> <body> <p></p> Airport List <xsl:for-each select="airportinfo/airport[code=$airportID]"> <br>Name: <xsl:value-of select="name"/></br> <br>Ticket Counter Opens: <xsl:value-of select="ticketopen"/></br> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> |
|
#2
|
|||
|
|||
|
From what I see, this isn't possible, I wanted to the same kind of thing a few weeks ago. Here's what I found.
You know that XML + XSL = HTML right ? This means that when you run your XML file, your browser uses the XSL to perform a transformation into HTML. What you are trying to do is to get a value that will be available AFTER the transformation, and use it BEFORE the transformation. This is simply not possible. What I was trying to do was to save a cookie from a page, and retrieve it in another page using the onload method of the BODY tag, the thing is that OnLoad is called AFTER the transformation, and I needed it BEFORE -> impossible. Sorry for the bad news ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML and Javascript Variables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|