This question is not related to math or operators, but rather a formatting or masking issue.
I am working on creating an order form that uses Javascript to tally and display the quantity and cost of each column in separate fields. I am trying to format the column cost to display with two decimal places, but the .toFixed(2) method does not seem to be working as expected (possibly due to it being a string), and I suspect it may be because the quantity and cost fields are set to readonly.
Any help would be greatly appreciated as I am currently stuck.
//example of tallying one column
<input type="number" min="0" value="0" name="proA#x#" class="input-mini proA qty1 coffee total">
$(document).on("change", ".qty1", function() {
var sum = 0;
$(".qty1").each(function(){
sum += +$(this).val();
});
$(".total1").val(sum);
$(".cost1").val(sum*9.00);
});
//item tally
<input type="number" id="D1" name="D1" class="input-mini uneditable-input total1" placeholder="0" readonly>
//item cost
<input type="number" id="" name="" class="input-mini uneditable-input cost1" placeholder="x 9.00" readonly >
Thank you for any assistance you can provide!