Exchange point for comma in price

Asked

Viewed 689 times

2

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

I need to exchange the .(dot) for ,(comma). How do I do?

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>

1 answer

1


Just put the function replace to exchange the point for the comma.

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

How are you :

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

As it should be :

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.