0
I’m having problems in displaying the data of a budget already imputed in the database. When accessing the detail is displaying the R$ NaN
in the currency fields.
Code of some functions:
orcamento.js
function sumTotal() {
var novo_total = 0;
$('#bodyOrcamento tr').each(function(index, element) {
if (!$(element).hasClass('etapa')) {
novo_total += Number($(element).children("td:nth-child(7)").html());
}
});
var custo_total = $('#custoTotal_orc');
custo_total.html(novo_total.toFixed(2));
}
function salvarOrcamento() {
var id = $("#codigo").val();
var descricao = $("#descricao_orc").html();
var empreendimento = $("#empreendimento_orc").data('id');
var custo = Number($("#custoTotal_orc").html());
}
THE HTML
<table class="table hide table-bordered grid" id="tabelaOrcamento">
<thead>
<tr class="">
<th scope="col" title="Item">Item</th>
<th scope="col" title="Código">Código</th>
<th scope="col" title="Descrição">Descrição</th>
<th scope="col" title="Unidade">Unidade</th>
<th scope="col" title="Custo Unitário">Custo Unitário</th>
<th scope="col" title="Quantidade">Quantidade</th>
<th scope="col" title="Custo Total">Custo Total</th>
<th scope="col" title="Ações">Ações</th>
</tr>
</thead>
<tbody id="bodyOrcamento"></tbody>
</table>
<div class="pull-right">
<span style="font-size:15px;">Valor Total:</span><br>
<span style="font-size:30px;"><b>R$ <span id="custoTotal_orc">0.00</span></b></span>
</div>
What’s inside the
td
from where you want to get the number? Just the number or has tags or something other than the number?– Sam
give a
console.log($(element).children("td:nth-child(7)").html())
and see if the return is a numberint
orfloat
– Máttheus Spoo
@sam, updated with HTML.
– aleestevao
You have to show the contents of
td
where the value comes from.– Sam