I have the following script in my HTML, what it does is simply check a checkbox whether or not it is selected and in case it is adding a value, my question is, how do I make this value to be formatted in currency? For example, instead of appearing 400.00 or 1455.80 it all appears together as an integer in case 400 and 145580, how do you show the values in real?
Script:
function check() {
var basic = 0;
var add = 0;
if(document.getElementById("cl45").checked) {
add += 145580;
}
if(document.getElementById("trigger").checked) {
add += 40000;
}
var p = basic + add;
var price ="R$ " + p;
document.getElementById('total2').innerHTML = price;
}
check();