Recalculate a tax in a single row and the value be sortable
Recalculate a tax in a single row and the value be sortable
wilsonrneto
Posts: 6Questions: 1Answers: 0
Dear friends,
Im new on jQuery and dataTables.
I need to make a function to recalculate a tax value by a input field and the new result be sortable.
[code]
function recalculaFator(id) {
var valor = $('#redutor-'+id).val();
var resposta = 0;
resposta = $('#preco-'+id).val().replace(",", ".") / valor;
$('#resultado-'+id).val(resposta.toFixed(4).replace(".", ","));
$('#fator-'+id).html(resposta.toFixed(4).replace(".", ","));
$('#rsdw').dataTable().fnDraw();
}
[/code]
Thanks for your help ;)
Im new on jQuery and dataTables.
I need to make a function to recalculate a tax value by a input field and the new result be sortable.
[code]
function recalculaFator(id) {
var valor = $('#redutor-'+id).val();
var resposta = 0;
resposta = $('#preco-'+id).val().replace(",", ".") / valor;
$('#resultado-'+id).val(resposta.toFixed(4).replace(".", ","));
$('#fator-'+id).html(resposta.toFixed(4).replace(".", ","));
$('#rsdw').dataTable().fnDraw();
}
[/code]
Thanks for your help ;)
This discussion has been closed.
Replies
[code]
$('#redutor', oTable.fnGetNodes()).keyup( function () {
var redutor = $('#redutor',this.parentNode.parentNode);
var preco = $('#preco',this.parentNode.parentNode);
var resultado = $('#resultado',this.parentNode.parentNode);
var fator = $('#fator',this.parentNode.parentNode);
if (isNaN(redutor.val()) || !redutor.val()) {
return;
}
var resposta = ( preco.val().replace(",", ".") / redutor.val() ).toFixed(4).replace(".", ",");
resultado.val(resposta);
fator.html(resposta);
oTable.dataTable().fnUpdate(resposta, this.parentNode.parentNode, 12);
fator.focus();
} );
[/code]