6
Could someone help me calculate the values in cents, transform the value 1.6 in 1.60.
Code:
$(document).ready(function () {
var $entrada = 0,
$saida = 0,
$total = 0;
$.each($("td[name='entrada']"), function() {
$entrada += parseFloat($(this).text().replace(",", "."));
});
$.each($("td[name='saida']"), function() {
$saida += parseFloat($(this).text().replace(",", "."));
});
$total = $entrada - $saida;
$("#totalEntrada").append("R$ " + $entrada);
$("#totalSaida").append("R$ " + $saida)
$("#totalGeral").append("R$ " + $total);
});
<body>
<h2>ENTRADA</h2>
<table width="198" border="1" id="table">
<tr>
<td width="39%">PRODUTO</td>
<td width="12%">VALOR</td>
</tr>
<tr>
<td>1</td>
<td name="entrada">100,00</td>
</tr>
<tr>
<td>2</td>
<td name="entrada">100,00</td>
</tr>
</table>
<h2>SAIDA</h2>
<table width="196" border="1">
<tr>
<td width="39%">DESCRICAO</td>
<td width="12%">VALOR</td>
</tr>
<tr>
<td>SAIDA</td>
<td name="saida">50,00</td>
</tr>
</table>
<h2>TOTAL</h2>
<table border="1">
<tr>
<td>TOTAL ENTRADA</td>
<td id="totalEntrada"></td>
</tr>
<tr>
<td>TOTAL SAIDA</td>
<td id="totalSaida"></td>
</tr>
<tr>
<td>TOTAL GERAL</td>
<td id="totalGeral"></td>
</tr>
</table>
</body>
Did it all work out? It worked?
– Paulo Costa