0

I am using the below javascript code in XSLT style sheet.It's working without for loop. But i got the error illegal syntax error near "<". Please help me to do this.

function activate(id)
      {
      try
      {
      alert('enter');
      var table = document.getElementById('billmain');
      var valueImp="";
      alert(table.rows.length)

      for(i=1; i <table.rows.length; i++)
      {
      valueImp = table.rows[i].cells[0].innerHTML;
      alert(valueImp);
      }
      return false;
      }catch(ex)
      {
      alert(ex.Message);

      }
      }
1
  • Or at least post the markup Commented Aug 17, 2013 at 5:09

1 Answer 1

2

Well an XSLT stylesheet is an XML document so XML syntax rules apply meaning you need to escape the < less-than sign as &lt; or use a CDATA section e.g.

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

<xsl:output method="html"/>

<xsl:template match="/">
  <html>
    <head>
      <title>Example</title>
      <script><![CDATA[
function activate(id)
      {
      try
      {
      alert('enter');
      var table = document.getElementById('billmain');
      var valueImp="";
      alert(table.rows.length)

      for(i=1; i <table.rows.length; i++)
      {
      valueImp = table.rows[i].cells[0].innerHTML;
      alert(valueImp);
      }
      return false;
      }catch(ex)
      {
      alert(ex.Message);

      }
      }
]]></script>
   </head>
   <body>
    <xsl:apply-templates/>
   </body>
 </html>
</xsl:template>

<!-- further templates go here -->
</xsl:stylesheet>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.