0
<script type="text/javascript">
$(document).ready(function() {
$("#somar").click(function(){
var total = 0;
var desconto = $("#desconto").val() != "" ? $("#desconto").val() : 0;
$('.input').each(function(){
var valor = Number($(this).val());
if (!isNaN(valor)) total += valor;
});
total = total - desconto;
$(".resultado").html(total.toFixed(2));
});
});
</script>
<script>
function imprimir(mesmo){
var conteudo = mesmo.parentElement.innerHTML,
tela_impressao = window.open('about:blank');
tela_impressao.document.write(conteudo);
tela_impressao.window.print();
tela_impressao.window.close();
}
</script>
You cannot calculate with COMMA, what you can do is turn the point into a comma in the function return. See the function replace of the JS
– Don't Panic
How do I do that?
– Usuario
var str = "5,8"; var str = str.replace(",", ".");
– user75204
Now what part of the code?
– Usuario
Let me explain these values already stay in an input that is received from another user I wanted to do after clicking calculate without putting the values in the input!
– Usuario