How to set auto 2 decimal number in input type=“text” in javascript

var zzz = parseFloat(numb).toFixed(2)
 
&&
 
function updateCost() {
    var amount = parseFloat(document.getElementById("amount").value),
        delivery = parseFloat(document.getElementById("delivery").value),
        total = amount + delivery,
        fixedrate =  total / 100 * 8.2,
        grandtotal = fixedrate + total;

    document.getElementById("total").innerHTML = total.toFixed(2);
    document.getElementById("amountdiv").innerHTML = amount.toFixed(2);
    document.getElementById("deliverydiv").innerHTML = delivery.toFixed(2);
    document.getElementById("grandtotal").innerHTML = grandtotal.toFixed(2);
    document.getElementById("fixedrate").innerHTML = fixedrate.toFixed(2);
}

$(function(){
    document.getElementById("amount").onchange =
        document.getElementById("delivery").onchange = updateCost;
});  

Comments

Popular posts from this blog

Script For Login, Logout and View Using PHP, MySQL and Bootstrap

PHP Ajax Login Validation Tutorial

Insert CheckBox and Radio button Data in MySQL Database Using PHP