calcular dois INPUT
Pessoal como faço pra calcular 2 valores e no terceiro mostrar o resultado em um input, consegui um script mais ele nao funciona com valores monetarios tipo 700.000,00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function id( el ){
return document.getElementById( el );
}
function total( un, qnt ){
return un - qnt;
}
window.onload = function(){
id('valor_unitario').onkeyup = function()
{
id('total').value = total( this.value , id('qnt').value );
}
id('qnt').onkeyup = function()
{
id('total').value = total( id('valor_unitario').value , this.value );
}
}
</script>
</head>
<body>
<form action="" method="post">
Valor Unitário: <input type="text" name="valor_unitario" id="valor_unitario" />
Quantidade: <input type="text" name="qnt" id="qnt" value="0" />
Total: <input type="text" name="total" id="total" readonly="readonly" />
</form>
</body>
</html>
</body>
</html>
</html>Discussão (2)
Carregando comentários...