JSFiddle - React, Tailwind, and code Playground
HTML
<form action="#">
<span id="price">2 490 грн</span>
<fieldset>
<label for="doorsSize">Суммировать к цене</label>
<select id="doorsSize">
<option value="0">0</option>
<option value="10">10</option>
<option value="20">20</option>
</select>
</fieldset>
<fieldset>
<label for="doorsSize">Суммировать еще к цене</label>
<select id="doorsSize">
<option value="0">0</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
</fieldset>
</form>
JavaScript
function formatPrice(_number,decimal,separator,decpoint,format_string)
{
var r=parseFloat(_number)
var exp10=Math.pow(10,decimal);
r=Math.round(r*exp10)/exp10;
rr=Number(r).toFixed(decimal).toString().split('.');
b=rr[0].replace(/(\d{1,3}(?=(\d{3})+(?:\.\d|\b)))/g,"\$1"+separator);
r=(rr[1]?b+ decpoint +rr[1]:b);
return format_string.replace('#', r);
}
alert(formatPrice(1000000.65,0,' ',',','# руб.'));
alert(formatPrice(1000000.65,2,' ',',','# руб.'));