I have a web form where users can register and pay to attend an event. It is set up so that they can book multiple seats with a single registration. Based on how many seats they book the form will calculate and populate the “amount” field.
The problem is that the amount format does not include the decimal and cents. If the amount is $55 then in the box it would show “55” instead of 55.00
Can anyone offer some insight on what the best way to edit this is so as to achieve this outcome? Thanks!
Amount Field:
<input type="text" name="Amount" id="Amount" class="cat_textbox" />
The page links to this JS file for the form:
(function($){
bookings = function() {
var bookingAmount = 55.00; //Booking amount in dollars
$('#seats').change(function() {
$('.webform').fadeIn("slow");
var noOfSeats = $("#seats option:selected").val(); //take the selected option from the dropdown
$('.hide').fadeOut("slow");
$('#BookingAllocation').val(noOfSeats); //set the number of seats
totalAmount = bookingAmount * noOfSeats;
$('#Amount').val(totalAmount);
for(var index = noOfSeats; index > 0; index--){
$('.person'+index).fadeIn("slow");
}
$('.total').html("<span>TOTAL:"+totalAmount+"</span>");
});
}
})(jQuery);
The form has this function in the head of the page:
function check(input) {
i = input.value.replace(/[^\d.]/g,'').split(".");
if(i.length>1) i[0] = i[0] + "." + i[1];
input.value = parseFloat(i[0]).toFixed(2);
}