Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2010, 04:06 AM
Authorized User
 
Join Date: Jul 2010
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Read table date fill in with xsl

Hi,

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...?

Thank you

Giambattista
 
Old July 21st, 2010, 04:14 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Your XSLT only outputs 1 table cell, so cells[1] will not return anything as this asks for the second table cell in a row. cells[0] gets the first one.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old July 21st, 2010, 04:40 AM
Authorized User
 
Join Date: Jul 2010
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

..postpone the complete code...

<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>

the script:

<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>

My objective is sum the value into 4 col...

This is the complete code...
 
Old July 21st, 2010, 05:10 AM
Authorized User
 
Join Date: Jul 2010
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I post the complete code:

xsl:

<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:

<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>

My objective is sum the 4 col...
 
Old July 21st, 2010, 05:14 AM
Authorized User
 
Join Date: Jul 2010
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by samjudson View Post
Your XSLT only outputs 1 table cell, so cells[1] will not return anything as this asks for the second table cell in a row. cells[0] gets the first one.
post the complete code..

Code:
		<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>
 
Old July 22nd, 2010, 09:01 AM
Authorized User
 
Join Date: Jul 2010
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is my code problem...

there is an other plus tag

<tr></tr>

Thanks!!

The script is ok!!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill in table based on start and end date drm237 Access 3 April 24th, 2007 07:55 AM
How to read cdata in xsl gantait XSLT 4 February 26th, 2007 04:34 AM
Read XSL File Neal Excel VBA 1 April 7th, 2006 06:47 AM
Fill a drop down box with table names? morpheus Classic ASP Basics 10 April 23rd, 2004 08:35 AM
fill a table Warbird Classic ASP Basics 2 August 5th, 2003 09:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.