I calculate with Javascript inputs

Asked

Viewed 43 times

3

function IBUTG() {
    $tt = $('[name=tempo_trabalho]');
    $vt = $('[name=valor_ibutg_trabalho]');
    $td = $('[name=tempo_descanso]');
    $vd = $('[name=valor_ibutg_descanso]');

    $ibutg = (($tt * $vt) + ($td * $vd)) / 60;

    $('[name=ibutg_calculado]').val($ibutg);
}

I’m getting Nan when performing this function, what can it be? Input values are in the 99.9 format

  • 2

    Missed the .val()

1 answer

6


Missed the .val() in the end

function IBUTG() {
    $tt = parseFloat($('[name=tempo_trabalho]').val());
    $vt = parseFloat($('[name=valor_ibutg_trabalho]').val());
    $td = parseFloat($('[name=tempo_descanso]').val());
    $vd = parseFloat($('[name=valor_ibutg_descanso]').val());

    $ibutg = (($tt * $vt) + ($td * $vd)) / 60;

    $('[name=ibutg_calculado]').val($ibutg);
}
  • Aff que burro kkkk. I even used parseFloat but it wasn’t working because I forgot the . val().

  • If this answer solved your problem don’t forget to mark it as right.

  • 1

    I’ll dial yes @Paulogustavo, just hoping to give the minimum time.

Browser other questions tagged

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