Apologies for the common question, but as I tried to find a direct answer to my problem on the forum it don't seem I found it.
See, I have an text input (id = avt_ht) in Javascript where I put a number received in form of a string, like this :
1 200,00
I take this value, convert it into a float with something like this :
var ht_txt = $("#avt_ht").val();
ht_txt = ht_txt.replace(' ', '');
var ht_val = parseFloat(ht_txt);
Then, I use it to make some calculation, like
var ttc_val = ht_val + tva_val;
Now my point is I want to convert these numbers again in order to give them the same format at my beginning. I tried somethings like this :
var ttc_txt = ttc_val.toLocaleString();
But It is not appropriate. I don't really know if I can use NumberFormat in JS like in PHP (it seems not to be the same way of using it), if I have to use a regex, etc...
Does someone knows how to do it ?
parseFloat('1200,00')only the '1200' part of the number is used, so strings like '1200,12' will not keep their decimal part, it must be '1200.12'.ht_txt.replace(' ', '');? I wonder if it was something to do with the fact that, if I change a unit, it doesn't show ",00"