Subject: [xsl] Using Javascript in XSL and hiding/unhiding text From: "Connor T. Fee" <ctf9y@xxxxxxxxxxxxxxxxxxxxx> Date: Sun, 08 Jun 2003 14:26:43 -0400 |
I am currently working on a website I was somewhat thrown into and am trying to update a page we have that uses XSL. This is an asp page that writes XSL on the fly which is used to view and XML document. I am currently trying to write a script so that when a user clicks on a county name that has children, the children either hide or unhide depending on thier current display style. This is actually very similar to the default xsl stylsheet in IE 5.0 (which sadly I, being a newbie can NOT understand). I am posting in the pertinent portion of my document and would appreciate some help. I know how to write the javascript function, but I do not know how to tell XSL to give unique identifiers to each of the children so I can access them directly. I have searched all over and have not seen this question answered anywhere so I hope someone can help me. The pertinent code: <% Dim fil, objFSO, afile, fieldlist, fieldcount, i, xslfilename, countyid Set objFSO = Server.CreateObject("Scripting.FileSystemObject") '******************************************************************** ***************** ' CREATE THE XSL FILE 'Create and name an xsl file Set afile = objFSO.CreateTextFile(Application("PathToRoot") &"\data\StateDatabase.xsl", True) 'Write out the beginning of the file (will remain the same for every file) afile.WriteLine("<?xml version=""1.0"" encoding=""ISO-8859-1""?>") afile.WriteLine("<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">") afile.WriteLine("<xsl:template match=""/"">") afile.WriteLine("<html>") afile.WriteLine(" <title>Agencies available</title>") afile.WriteLine(" <head><script language=""javascript""><xsl:comment><![CDATA[") afile.WriteLine(" Response.CacheControl = ""no-cache""") afile.WriteLine(" function test(toHide) {") afile.WriteLine(" toHide.style.display=""none""") afile.WriteLine(" return true") afile.WriteLine(" }") afile.WriteLine(" ]]></xsl:comment></script></head>") afile.WriteLine(" <body leftmargin=""0"" rightmargin=""0"" topmargin=""0"" bottommargin=""0"">") afile.WriteLine(" <table border=""1"" width=""100%"" cellspacing=""0"">") afile.WriteLine(" <xsl:for-each select=""US/STATE [StateAbbrev='" & Request.item("abbrev") & "']"">") afile.WriteLine(" <tr bgcolor=""#003366"" id=""one"">") afile.WriteLine(" <td height=""*"" align=""center""><font size=""3"" face=""Arial"" color=""#ffff99""><B><xsl:value-of select=""StateName""/></B></font></td>") afile.WriteLine(" </tr>") afile.WriteLine(" <xsl:for-each select=""COUNTY"">") afile.WriteLine(" <xsl:choose>") afile.WriteLine(" <xsl:when test=""Data>'0'"">") afile.WriteLine(" <tr bgcolor=""#FFFF99"" onClick=""test(this)"">") afile.WriteLine(" <td width=""*""><font size=""2"" face=""Arial"" color=""Black""><B><xsl:value-of select=""CountyName""/></B></font></td>") afile.WriteLine(" </tr>") afile.WriteLine(" </xsl:when>") afile.WriteLine(" <xsl:otherwise>") afile.WriteLine(" <tr bgcolor=""#CCCCCC"" onClick=""test(this)"">") afile.WriteLine(" <td width=""*""><font size=""2"" face=""Arial""><xsl:value-of select=""CountyName""/></font></td>") afile.WriteLine(" </tr>") afile.WriteLine(" </xsl:otherwise>") afile.WriteLine(" </xsl:choose>") afile.WriteLine(" <xsl:for-each select=""AGENCY"">") afile.WriteLine(" <tr style=""display:none"" >") afile.WriteLine(" <td bgcolor=""#FFFF99""><font size=""2"" face=""Arial"">- <xsl:value-of select=""AgencyName""/></font></td>") afile.WriteLine(" </tr>") afile.WriteLine(" </xsl:for-each>") afile.WriteLine(" </xsl:for-each>") afile.WriteLine(" </xsl:for-each>") afile.WriteLine(" </table>") afile.WriteLine(" </body>") afile.WriteLine(" </html>") afile.WriteLine("</xsl:template>") afile.WriteLine("</xsl:stylesheet>") 'Close text File afile.close Thank you all for your help in advance. Connor Fee GRASP Administrator http://secure.sys.virginia.edu XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: How to split sets into se, Dimitre Novatchev | Thread | RE: [xsl] Using Javascript in XSL a, Jarno . Elovirta |
Re: [xsl] Schematron can have varia, Oleg Tkachenko | Date | RE: [xsl] Using Javascript in XSL a, Jarno . Elovirta |
Month |