1
Hello I am with this code and I would like to make the sum only of the category "CREDIT" someone gives a force for friend here.
$(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);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<h2>ENTRADA</h2>
<table width="198" border="1" id="table">
<tr>
<td width="39%">PRODUTO</td>
<td width="12%">VALOR</td>
<td width="12%">CATEGORIA</td>
</tr>
<tr>
<td>1</td>
<td name="entrada">100,00</td>
<td name="CRED">PROVEDOR</td>
</tr>
<tr>
<td>2</td>
<td name="entrada">10,00</td>
<td name="CREDITO">CREDITO</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>
<tr>
<td>CREDITO</td>
<td id="CREDITO"></td>
</tr>
</table>
</body>
I didn’t get it right, what do you want to add with "CREDIT" (and that appears in the field "CREDIT" that is blank)? It is the credit plus the overall total (10+60 in the case)?
– gustavox
The totals are perfect I just want to separate the sum of the credits @gustavox
– Hemerson Prestes