I saw a few rounding examples but i can't figure out how to code mine, here is what I have. I need to round the val to two decimal places, this is a dollar value.
I looked at other posts with similar question but i can't figure it out on my own code, any help is appreciated!
$(function() {
$("#bpComputers").change(function() {
var suPrice = 19.99;
var value=$(this).val();
if(value === "---") { $("#amountInDollars").val("Select a Number"); }
if(value === "1") { $("#amountInDollars").val(1 * suPrice); }
if(value === "2") { $("#amountInDollars").val(2 * suPrice); }
if(value === "3") { $("#amountInDollars").val(3 * suPrice); }
if(value === "4") { $("#amountInDollars").val(4 * suPrice); }
});
});
Found a solution to my issue...
$(function() {
$("#bpComputers").change(function() {
//Define Sign Up and Setup Fee Costs
var suPrice = 19.99;
var suSetupFee = 0.00;
//Define and Calculate Computer Costs
var onePC = 1 * suPrice;
var twoPCs = 2 * suPrice;
var threePCs = 3 * suPrice;
var fourPCs = 4 * suPrice;
//Define a Selector and Value for costPerPC
var value = $(this).val();
//Populate costPerPC Based on Computers Selected
if(value === "---") { $("input[name='costPerPC']").val("0.00"); }
if(value === "1") { $("input[name='costPerPC']").val(onePC.toFixed(2)); }
if(value === "2") { $("input[name='costPerPC']").val(twoPCs.toFixed(2)); }
if(value === "3") { $("input[name='costPerPC']").val(threePCs.toFixed(2)); }
if(value === "4") { $("input[name='costPerPC']").val(fourPCs.toFixed(2)); }
});
});