Paul Rajs

Paul Rajs

  • NA
  • 641
  • 135.7k

Jquery Sum Does not give Exact Output ()

Aug 31 2016 6:45 AM

hi developers
Am using the jquery for Calculate sum.

Total , Tax , GrandTotal
GrandTotal=Total + Total*Tax/100;

if 1.
Total = 1000.45
Tax =124.25
GrandTotal Will be Value =2242.95 but it gives like Value =2243.51

Total = 200.50
Tax =10.25
GrandTotal Will be Value =221.00 but it gives like Value =221.05

i can't able to Resolve this Critical problem. this is very Important for my project.
this will be go to Quotation.

My Code is

<script src="Tracking/js/jquery.js" type="text/javascript"></script>

function txtpercentage() {
var ch1 = $("#txtQUOTETotal").val();
var tax = $("#txtQUOTETax").val();

var grandTotal;
var ch3 = ch1 * tax / 100;
grandTotal = parseFloat(ch1) + parseFloat(ch3);



Client side Aspx Code


<asp:Label ID="Label32" runat="server" Text="Total"></asp:Label>
<span style="float:right"><span style="color:red;">*</span> : </span></td>
<asp:TextBox ID="txtQUOTETotal" runat="server" AutoComplete="off" Width="250px"
<asp:RequiredFieldValidator ID="RequiredFieldValidator24" runat="server"
ControlToValidate="txtQUOTETotal" ErrorMessage="*" ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:Label ID="Label33" runat="server" Text="Tax"></asp:Label>
<span style="float:right"><span style="color:red;">*</span> : </span></td>
<asp:TextBox ID="txtQUOTETax" runat="server" AutoComplete="off" Width="250px" onkeyup="txtpercentage()"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator25" runat="server"
ControlToValidate="txtQUOTETax" ErrorMessage="*" ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:Label ID="Label36" runat="server" Text="Grand Total"></asp:Label>
<span style="float:right"><span style="color:red;">*</span> : </span></td>
<asp:Label ID="txtQUOTEGrandTotal" runat="server" class="add"
AutoComplete="off" Width="250px"></asp:Label>


so anyone know how to fix this problem.
Please help to me.

thanks with

Answers (5)