tags:

views:

14

answers:

3

I don't have the problem.

The table is so:

    <table id="table">
        <tr>
                <th>value</th>
                <th>Total</th>
        </tr>
        <tr>
                <td>x</td>
                <td>100</td>
        </tr>
        <tr>
                <td>y</td>
                <td>101</td>
        </tr>
    </table>

the script is:

var table = document.getElementById("table");   
var value;
var total = 0;

for(i = 1; i < table.rows.length; i++){

    value = table.rows[i].cells[1].innerHTML;
    total += parseInt(value);       
}

This is ok!!!

but if the table is fill in from xml file with xsl:

            <xsl:for-each select="fatture/fattura">
                <tr>
                    <td><xsl:value-of select="numero"/></td>                        
                </tr>
            </xsl:for-each>

the top script is not ok...

value = table.rows[i].cells[1].innerHTML;
value = table.rows[i].cells[1].value;
...

What is the function for read the table tag fill in with xsl...?

A: 

Shouldn't it be

<xsl:for-each select="fatture/fattura">
  <tr>
    <td><xsl:value-of select="name-or-something"/></td>
    <td><xsl:value-of select="numero"/></td>
  </tr>
</xsl:for-each>

?

Because your script is explicitly referencing the second cell

table.rows[i].cells[1].innerHTML
//------------------^

but your current XSLT generates one cell only.

Tomalak
A: 

pospone the complete code...

the xsl table..

Data Numero Cliente P_iva Cliente Imponibile Iva ....

the script is...

        <script type="text/javascript">             
        <![CDATA[
                var table = document.getElementById('table1');
                var Imponibile = document.getElementById('TotImp');
                var Iva = document.getElementById('TotIva');
                var Totale = document.getElementById('Tot');    

                var valueImp, valueIva;
                var totalImp = 0;
                var totalIva = 0;
                var Tot = 0;
                var i;

                for(i=1; i<table.rows.length; i++){
                    valueImp = table.rows[i].cells[4].innerHTML;

                    alert(valueImp);
                }
        ]]>
        </script>
Giambattista Stigliano
A: 

the table have other rows...

the complete table and script are:

    <table border="1"  id="table1">
        <tr>
                <th>Data</th>
                <th>Numero</th>
                <th>Cliente</th>
                <th>P_iva Cliente</th>
                <th>Imponibile</th>
                <th>Iva</th>
        </tr>
        <tr>

        </tr>
            <xsl:for-each select="fatture/fattura">
                <tr>
                    <td><xsl:value-of select="data"/></td>
                    <td><xsl:value-of select="numero"/></td>
                    <td><xsl:value-of select="cliente"/></td>
                    <td>....</td>
                    <td><xsl:value-of select="imponibile"/></td>
                    <td><xsl:value-of select="iva"/></td>
                </tr>
            </xsl:for-each>
    </table>

        <script type="text/javascript">             
        <![CDATA[
                var table = document.getElementById('table1');
                var Imponibile = document.getElementById('TotImp');
                var Iva = document.getElementById('TotIva');
                var Totale = document.getElementById('Tot');    

                var valueImp, valueIva;
                var totalImp = 0;
                var totalIva = 0;
                var Tot = 0;
                var i;

                for(i=1; i<table.rows.length; i++){
                    valueImp = table.rows[i].cells[4].innerHTML;

                    alert(valueImp);
                }
        ]]>
        </script>
Giambattista Stigliano