开发者

Read table date fill in with xsl

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="n开发者_如何学JAVAumero"/></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...?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜