Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml and use of javascript

Status
Not open for further replies.

rxg00u

Programmer
Apr 11, 2002
16
GB
hi there,
quick question regarding javascript and xml.
I am using a single xml document and a single xslt.
I would like to display half the document until the user clicks a button and then display the second half.
I have the following code
Code:
<xsl:template match=&quot;EXAMML&quot;>
      <html>
 	 <head>
 	 <link rel=&quot;stylesheet&quot; href=&quot;exam.css&quot;        type=&quot;text/css&quot; />
	 <title>
 	 	Exam paper: <xsl:value-of select = &quot;COVERPAGEINFO/COURSE&quot;/>
 	 </title>
	 <body>
	   <div align = &quot;right&quot;><xsl:value-of select =&quot;COVERPAGEINFO/COURSE/@code&quot;/></div><br/>
	 </body>

	 <script type=&quot;text/javascript&quot;>
	 function myfunction()
	 {
	   document.write(<xsl:apply-templates select=&quot;COVERPAGEINFO&quot;/>)
	 }
	 </script>
    </head>
	
    <form>
       <input type=&quot;button&quot; 
         onclick=&quot;myfunction()&quot; 
         value=&quot;Call function&quot;>
       </input>
    </form>
ending tags are here
I have also a template that matches the call within the function.
this does not seem to work (it works fine when i just output text to screen), I am completely new to the use of javascript within an xslt so any help or pointers in the right direction would be much appriciated. Also is this the best way of doing this or is there a method that does not require the use of javascript?
Thanks for all your time
rxg00u






 
Could it be complaining that your <body> is enclosed in your <head> (sounds painful!)? Shouldn't it be

Code:
<xsl:template match=&quot;EXAMML&quot;>
      <html>
      <head>
      <link rel=&quot;stylesheet&quot; href=&quot;exam.css&quot;        type=&quot;text/css&quot; />
     <title>
          Exam paper: <xsl:value-of select = &quot;COVERPAGEINFO/COURSE&quot;/>
      </title>

     <script type=&quot;text/javascript&quot;>
     function myfunction()
     {
       document.write(<xsl:apply-templates select=&quot;COVERPAGEINFO&quot;/>)
     }
     </script>
    </head>
     <body>
       <div align = &quot;right&quot;><xsl:value-of select =&quot;COVERPAGEINFO/COURSE/@code&quot;/></div><br/>
    
    <form>
       <input type=&quot;button&quot; 
         onclick=&quot;myfunction()&quot; 
         value=&quot;Call function&quot;>
       </input>
    </form>
    </body>
-- Chris Hunt
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top