affecter une valeur js dans une table html
Bonjour;
mon pb:
j 'ai une table html, qui se remplie d'une base de donnée, et il y a des calcules de toto qui sont font a l'aide d'une fonction js.
je veux exporter cette table en exel , ttes les données s'affichent, seulement celles qui ont été calculées par la fonction js.
quand j'ai fais "ctrl+u" pour voir le code source de page, je retrouve pas les toto ds le champ "value" de ma table html.malgres que dans la fontion js j'attribue la valeur calculée au champ!
comment faire svp?
voici ma table:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| <table width="75%" class="tablesorter" border="0" cellspacing="2" cellpadding="1"> <!-- id="myTable" -->
<thead>
<tr>
<th width="19%" rowspan="2" ><span>Tranches ages</span></th>
<th colspan="10" align="center" >Tranches anciennetés</th>
</tr>
<tr>
<?php
for($i=0; $i< $countAnciente; $i++)
echo "<th><strong width='9%'>".$ancientes[$i]."</strong></th>";
?>
</tr>
</thead>
<tbody class="tableorder">
<?php
for($i=0, $j=0; $i< $countAges; $i++)
{
echo "<tr>
<td><strong>".$ages[$i]."</strong></td>";
for($r=0; $r< $countAnciente; $r++)
if (($ancientes[$r] != "TOTAL") && ($ages[$i] != "TOTAL"))
{ echo "<td><input name='tab".$r."".$i."' type='text' size='10' value='".$mat1[$j++]['nbre']."' disabled='true' /></td>";
}
elseif (($ancientes[$r] != "TOTAL") && ($ages[$i] == "TOTAL"))
{ echo "<td><input name='TotoC".$r."".$i."' type='text' size='10' value='' /></td>";
}
elseif((($ancientes[$r] == "TOTAL") && ($ages[$i] != "TOTAL")))
{ echo "<td><input name='TotoL".$r."".$i."' type='text' size='10' value='' /></td>";
}
else { echo "<td><input name='TotoDeToto' type='text' size='10' value='' /></td>";
}
echo "</tr>";
} ?>
</tbody>
</table> |
et voici ma fonction js:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <script type="text/javascript">
function f()
{
var colon = <?php echo $countAnciente-1; ?>;
var lign = <?php echo $countAges-1; ?>;
var obj, obj1; var sommLign = 0, sommColon= 0;
var sommL =0, sommC =0;
for(var i=0; i<lign; i++)
{
sommLign = 0, sommColon= 0;
for(var j=0; j<colon; j++)
{
obj = document.getElementsByName('tab'+i+j); //alert('le champ a pour valeur : "'+obj[0].value+"'");
sommColon += parseInt(obj[0].value);
obj1 = document.getElementsByName('tab'+j+i);
sommLign += parseInt(obj1[0].value);
} //fin boucle interne
var totoL = document.getElementsByName('TotoL'+j+i);
totoL[0].value = sommLign; sommL += parseInt( sommLign );
var totoC = document.getElementsByName('TotoC'+i+j);
totoC[0].value = sommColon; sommC += parseInt( sommColon );
}//FIN boucle externe
//if(sommC != sommL) window.alert("Erreur a la saisie de la somme...");
var totoDeToto = document.getElementsByName('TotoDeToto');
totoDeToto[0].value = sommL;
}
window.onload=f();
</script> |
Merci.