Change point per comma in price

2

Good morning, I have this code to update the total.

I need to change the. (dot) by, (comma). How do I?

Code:

<script type="text/javascript">
$(document).ready(function() {

 $("#evento_quantidade").change(function() {
 var qtd = $(this).val();
 var valor = $("#precoSoma").val();
 var calculo = qtd * valor;
 var n = calculo.toFixed(2);     
 $("#total_compra").val(n);

 });


 });
 </script>
    
asked by anonymous 24.06.2017 / 16:32

1 answer

1

Just put the replace function to change the point through the comma.

Try changing the code below and tell me later if it worked

How are you:

$("#total_compra").val(n);

How to stay:

$("#total_compra").val(n.replace(".", ","));
    
24.06.2017 / 16:40