ecpeel
asked on
result to input box exceeds 2 decimal format - jQuery
input starting at "'reservation for room only"
1. 15.47
2. 25.26
3. 13.46
4. 1.51
5. 1.51
7. 27.8
The totalbox returns in long decimal format.
add a number to the 8th input box 16 or above and it snaps back to 2 digit format.
At all times the cal is accurate, just the display is the problem.
thx
1. 15.47
2. 25.26
3. 13.46
4. 1.51
5. 1.51
7. 27.8
The totalbox returns in long decimal format.
add a number to the 8th input box 16 or above and it snaps back to 2 digit format.
At all times the cal is accurate, just the display is the problem.
thx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://code.jquery.com/jquery-1.4.2.min.js" language="javascript"></script>
</head>
<body>
<table cellpadding="2" cellspacing="2" border="0">
<TR>
<TD width="381"><table border="0" cellpadding="0" cellspacing="0" width="85%">
<table id="totals">
<tr>
<td></td>
<td></td>
<td align="center"><STRONG>Yes</STRONG></td>
<td align="center"><STRONG>No</STRONG></td>
<td align="center"><STRONG>Amount</STRONG></td>
</tr>
<tr>
<td>1.</td>
<td width="270">For Reservation of Room Only</td>
<td align="center"><input type="radio" name="h_reservation" value="Y" <cfif form.h_reservation EQ "Y"> checked</cfif>></td>
<td align="center"><input name="h_reservation" type="radio" value="N" checked <cfif form.h_reservation EQ "N" OR form.h_reservation EQ "">checked</cfif> ></td>
<td align="center"><input type="text" class="charges" name="h_reservation_amount" value="10" size="8"></td>
</tr>
<tr>
<td>2.</td>
<td width="270">Guest Room(s) (room and tax only)</td>
<td align="center"><input type="radio" name="h_guest_room" value="Y"<cfif form.h_guest_room EQ "Y"> checked</cfif>></td>
<td align="center"><input name="h_guest_room" type="radio" value="N" checked checked<cfif form.h_guest_room EQ "Y" OR form.h_guest_room EQ ""> checked</cfif>></td>
<td align="center"><input type="text" class="charges" name="h_guest_room_amount" value="20" size="8"></td>
</tr>
<tr>
<td>3.</td>
<td width="270">Long Distance Calls</td>
<td align="center"><input type="radio" name="h_long_calls" value="Y"></td>
<td align="center"><input type="radio" name="h_long_calls" value="N" checked></td>
<td align="center"><input type="text" class="charges" name="h_long_calls_amount" value="30" size="8"></td>
</tr>
<tr>
<td>4.</td>
<td width="270">Local Calls</td>
<td align="center"><input type="radio" name="h_local_calls" value="Y"></td>
<td align="center"><input type="radio" name="h_local_calls" value="N" checked></td>
<td align="center"><input type="text" class="charges" name="h_local_calls_amount" value="40" size="8"></td>
</tr>
<tr>
<td>5.</td>
<td width="270">Catering Functions</td>
<td align="center"><input type="radio" name="h_catering" value="Y"></td>
<td align="center"><input type="radio" name="h_catering" value="N" checked></td>
<td align="center"><input type="text" class="charges" name="h_catering_amount" value="50" size="8"></td>
</tr>
<tr>
<td>6.</td>
<td width="270">Rental Meeting Room</td>
<td align="center"><input type="radio" name="h_meeting_room" value="Y"></td>
<td align="center"><input type="radio" name="h_meeting_room" value="N" checked></td>
<td align="center"><input type="text" class="charges" name="h_meeting_room_amount" value="15" size="8"></td>
</tr>
<tr>
<td>7.</td>
<td width="270">Audio/Visual Equipment</td>
<td align="center"><input type="radio" name="h_equipment" value="Y"></td>
<td align="center"><input type="radio" name="h_equipment" value="N" checked></td>
<td align="center"><input type="text" class="charges" name="h_equipment_amount" value="25" size="8"></td>
</tr>
<tr>
<td>8.</td>
<td>Exhibit(s)</td>
<td align="center"><input type="radio" name="h_exhibit" value="Y"></td>
<td align="center"><input type="radio" name="h_exhibit" value="N" checked></td>
<td align="center"><input type="text" class="charges" name="h_exhibit_amount" value="35" size="8"></td>
</tr>
<tr>
<td>9.</td>
<td>Other:
<input type="text" name="h_other_name" value="" size="12"></td>
<td align="center"><input type="radio" name="h_other" value="Y"></td>
<td align="center"><input type="radio" name="h_other" value="N" checked></td>
<td align="center"><input type="text" class="charges" name="h_other_amount" value="45" size="8"></td>
</tr>
</table>
</TD>
</TR>
<TR>
<TD><table border="0" cellpadding="2" cellspacing="2">
<table>
<tr>
<td align="right"><strong>Room rate per night:</strong></td>
<td><input type="text" name="h_room_rate" value="#form.h_room_rate#"></td>
</tr>
<tr>
<td align="right"><strong>Tax: (%)</strong></td>
<td><input type="text" name="h_tax" value="#form.h_tax#"></td>
</tr>
<tr>
<td align="right"><strong>Sub Total:</strong></td>
<td><input type="text" name="h_sub_total" value="#form.h_sub_total#"></td>
</tr>
<tr>
<td align="right"><strong>No. of days:</strong></td>
<td><input type="text" name="h_num_days" value="#form.h_num_days#"></td>
</tr>
<tr>
<td align="right"><strong>No. of participants:</strong></td>
<td><input type="text" name="h_num_people" value="#form.h_num_people#"></td>
</tr>
<tr>
<td align="right"><strong>Other Amount:</strong></td>
<td><input type="text" name="h_other_charge_amount" value="#form.h_other_charge_amount#"></td>
</tr>
<tr>
<td align="right"><strong>Total:</strong></td>
<td><input type="text" name="h_total_charge" value="#form.h_total_charge#"></td>
</tr>
</table></TD>
</TR>
</table>
<input type="text" id="totalBox" />
</body>
<script>
$(document).ready(function(){
$("#totalBox").val(addBoxes());
$(".charges").change(function(){
$("#totalBox").val(addBoxes());
})
function addBoxes() {
var result = 0;
$(".charges").each(function(){
result = result + parseFloat($(this).val());
});
return result;
}
});
</script>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for delay. I was away from the computer.
Thanks for the response I'll be back at you in a jiffy.
Thanks for the response I'll be back at you in a jiffy.
ASKER
Excellent.
Thanks again hielo!
Thanks again hielo!
result = result + parseFloat($(this).val()).