Tabela dinamica somando seus valores
Tenho esse formulário dinamico porem a primeira linha ele mutiplica qtde por vlrunt, porem qdo eu add a segunda linha o java nao funciona como fazer para funcionar
sendo que ainda tem que somar tudas as linhas no total
<script type="text/javascript">
$(function () {
function removeCampo() {
$(".removerCampo").unbind("click");
$(".removerCampo").bind("click", function () {
if($("tr.linhas").length > 1){
$(this).parent().parent().remove();
}
});
}
$(".adicionarCampo").click(function () {
novoCampo = $("tr.linhas:first").clone();
novoCampo.find("input").val("");
novoCampo.insertAfter("tr.linhas:last");
removeCampo();
});
$("vlrunt").keyup(function(){
var qtde = $("#qtde").val();
var vlrunt= $("#vlrunt").val();
$("#vlrsub").val(parseFloat(vlrunt) * parseFloat(qtde));
});
});
</script>
<form method="post" name="formoferta" action="envia1.php">
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" id="formoferta2">
<tr>
<th>Und</th>
<th>Descrição</th>
<th>Imagem<br>Produto</th>
<th>Classificação<br>Fiscal</th>
<th>Qtde</th>
<th>Vlr. Unitario</th>
<th>Vlr. Subtotal</th>
<th colspan="2">Prazo de<br>Entrega</th>
</tr>
<tbody>
<tr class="linhas">
<td><input type="text" name="und[]" id="und" style="text-align:center" /></td>
<td><textarea name="desc[]" id="desc" cols="25" rows="5"> </textarea></td>
<td><textarea name="img[]" id="img" cols="20" rows="5"> </textarea></td>
<td><input type="text" name="clfiscal[]" id="clfiscal" style="text-align:center" /></td>
<td class="class_unit"><input type="text" name="qtde[]" id="qtde" style="text-align:center" /></td>
<td class="class_quant"><input type="text" name="vlrunt[]" id="vlrunt" style="text-align:center" /></td>
<td class="class_total"><input type="text" name="vlrsub[]" id="vlrsub" style="text-align:center" /></td>
<td><input type="text" name="prazo[]" id="prazo" style="text-align:center" /></td>
<td><a href="#" class="removerCampo" title="Remover linha"><img src="_admin/_imagens/excluir.gif" border="0" id="excluir" /></a></td>
</tr>
<tbody>
<tr>
<td colspan="9">
<strong>TOTAL:</strong></td>
</tr>
<tr>
<td colspan="9">
<a href="#" class="adicionarCampo" title="Adicionar item"><img src="_admin/_imagens/inserir.gif" border="0" / id="inserir"></a></td>
</tr>
<tr>
<td align="right" colspan="9"><input type="submit" id="btn-cadastrar" value="ENVIAR OFERTA" /></td>
</tr>
</table>
</form>Discussão (11)
Carregando comentários...