I want the sum of two text box values
Total Balance + Net Balance
In the textbox of Balance.
I wrote the following Jquery from the link
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=TextBox3]").val(parseInt($("[id*=TextBox1]").val()) + parseInt($("[id*=TextBox2]").val()));
});
</script>
I want the sum of gridview rows like that
Product Qty Rate Total
A 2 100 200
B 3 100 300
C 4 100 400
Balance = 5000 (this will be fetched from database)
NetBalance = 900 (this will be rowTotal if 3 rows selected then
sum of 3 rows. if 5 rows is selected then the sum of 5 rows)
Total Balance = 5900 (Balance + NetBalance)
how to get solution please.
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=txtPaid]").keyup(function () {
var rowtotal = $(this).closest('tr').find('[id*=txtNet]').val();
var paid = $(this).val();
$(this).closest('tr').find('[id*=txtRem]').val(parseFloat(rowtotal) - parseFloat(paid));
});
})
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function CalculateSumTotal() {
var grandTotal = 0;
$("[id*=lblTotal]").each(function () {
grandTotal = grandTotal + parseFloat($(this).html());
});
$('[id*=txtTotal]').val(grandTotal);
// $('[id*=txtTotal]').val(grandTotal + parseFloat($("[id*=txtBalance]").val());
}
</script>
<div class="content-wrapper" style="background-color: blue;">
<div class="content">
<div class="connectedSortable" style="margin-left: 10px;">
<div class="col-sm-1">
</div>
<div class="col-sm-12">
<div class="modal-content">
<div class="modal-header" style="background-color: #4682B4; color: #fff">
<strong><span class="fa fa-signal"></span> Purchase Order</strong>
</div>
<div class="modal-body">
<div class="form-group">
<div class="row">
<div class="col-sm-12 ">
<div class="table-responsive">
<asp:GridView ID="GridView1" runat="server" AllowPaging="false" Class="table table-striped table-bordered table-hover"
AutoGenerateColumns="false" RowStyle-Wrap="false" HeaderStyle-Wrap="true" ShowFooter="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="checkAll" runat="server" onclick="checkAll(this);" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product ID" ItemStyle-Width="150">
<ItemTemplate>
<asp:Label ID="lblCode" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="200px" DataField="P_Name" HeaderText="Product Name" />
<asp:BoundField ItemStyle-Width="100px" DataField="BSize" HeaderText="Bag Size" ItemStyle-CssClass="bag" />
<asp:TemplateField>
<HeaderTemplate>
Bag No / Qty
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Text="0" class="field1 form-control" Width="100"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Rate
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="txtRate" runat="server" Text="0" class="field2 form-control" Width="100" ItemStyle-CssClass="price"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Discount
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="txtDiscount" runat="server" Text="0" class="field3 form-control" Width="100" ItemStyle-CssClass="discount"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Net
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="txtNet" runat="server" Text="0" class="field4 form-control" Width="100" ItemStyle-CssClass="pay"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Paid
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="txtPaid" runat="server" Text="0" class="field5 form-control" Width="100" ItemStyle-CssClass="paid"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
RemBal
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text="0" class="field6 form-control" Width="100" ItemStyle-CssClass="rem"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total">
<ItemTemplate>
<asp:Label ID="lblTotal" runat="server" Text="0" class="control-label"></asp:Label>
<asp:HiddenField ID="hdnfldBag" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
Grand Total:
<asp:Label ID="lblGrandTotal" runat="server" Text="0"></asp:Label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</asp:Content>