Hi,
I am using jQuery function to calculate total of item price (label) multiply by quantity (textbox), this is working fine so far.
Also, I added additional label for shipping which getting the data from rbl object, also working fine.
The calculation I'm trying to get is sum of total+shipping, once I add this code i'm getting strange numbers on the total label.
Here is the total+shipping code:$("[id*=lblTotalFishShipping]").html(parseFloat($(".sumOrder").html()) + parseFloat($("[id*=lblTotalFishShipping]").html()));
Here is the full function:
<script type="text/javascript">
$(function () {
$("[id*=quoteOrderAmount]").val("0");
});
$("[id*=quoteOrderAmount]").live("change", function () {
if (isNaN(parseInt($(this).val()))) {
$(this).val('0');
} else {
$(this).val(parseInt($(this).val()).toString());
}
});
$("[id*=quoteOrderAmount]").live("keyup", function () {
if (!jQuery.trim($(this).val()) == '') {
if (!isNaN(parseFloat($(this).val()))) {
var row = $(this).closest("tr");
$("[id*=lblTotal]", row).html(parseFloat($(".price", row).html()) * parseFloat($(this).val()));
$("[id*=lblTotalFishShipping]").html(parseFloat($(".sumOrder").html()) + parseFloat($("[id*=lblTotalFishShipping]").html()));
}
} else {
$(this).val('');
}
var grandTotal = 0;
$("[id*=lblTotal]").each(function () {
grandTotal = grandTotal + parseFloat($(this).html());
});
$("[id*=lblGrandTotal]").html(grandTotal.toString());
});
</script>
Here is the html:
<table border="1" frame="border" width="350px">
<tr>
<td class="style9" colspan="2">Order Summary (estimated)</td>
</tr>
<tr>
<td class="style8">Grand Total (fish):</td>
<td class="style10">$<asp:Label ID="lblGrandTotal" runat="server" Text="0" CssClass="sumOrder"></asp:Label>
</td>
</tr>
<tr>
<td class="style8">Shipping:</td>
<td class="style10">$<asp:Label ID="lblShipping" runat="server" Text="0" CssClass="sumOrder"></asp:Label>
</td>
</tr>
<tr>
<td class="style4">Total (USD):</td>
<td class="style11">$<asp:Label ID="lblTotalFishShipping" runat="server" Text="0"></asp:Label>
</td>
</tr>
</table>
Can you please help me to understand why it doesn't work?
Many Thanks,
YP