Nan non-numeric number return in PHP

Asked

Viewed 102 times

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

    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?

  • give a console.log($(element).children("td:nth-child(7)").html()) and see if the return is a number int or float

  • @sam, updated with HTML.

  • You have to show the contents of td where the value comes from.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.