2

I have an XSL file and there is HTML part of it which I am writing my javascript function inside it as

<script type="text/javascript" language="JavaScript" >
    function Toggle_tbody(obj)
    {
        var body = document.getElementsByTagName("tbody");
        if( obj.innerText == 'Expand all' ) 
        {
            obj.innerText = 'Collapse all';
            d = 'inline';
        } 
        else 
        {
            obj.innerText = 'Expand all';
            d = 'none';
        }

        var length = body.length
        for(var i = 0; i < length; i++) {
            document.getElementById("demo").innerHTML = length;
        }
    }
</script>

But I have an error while compiling an it says:

XML Parsing error at line 164: StartTag: invalid element name

I should mention that line 164 is the beginning of for loop.

Would anyone let me know where is the error because as I see there shouldn't be any.

Saber
  • 133
  • 1
  • 9

1 Answers1

1

Thanks @RohanKumar for the hint.

Then here I found that it should be as

<script type="text/javascript" language="JavaScript" >
    function Toggle_tbody(obj)
    {
        var body = document.getElementsByTagName("tbody");
        if( obj.innerText == 'Expand all' ) 
        {
            obj.innerText = 'Collapse all';
            d = 'inline';
        } 
        else 
        {
            obj.innerText = 'Expand all';
            d = 'none';
        }

        //<![CDATA[
        var length = body.length
        for(var i = 0; i < length; i++) {
            document.getElementById("demo").innerHTML = length;
        }
        //]]>
    }
</script>
Saber
  • 133
  • 1
  • 9