locked
Calculate Amount Based On Conditions RRS feed

  • Question

  • User2033107836 posted

    Hello

    This is my Gridview in asp.net 2.0 C#

    <asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource1" >
                <Columns>
                
                 <asp:TemplateField>
                               <HeaderTemplate>
                    <asp:CheckBox ID="chkHeader" runat="server" Height="20px" Width="20px" CssClass="chkHeader" AutoPostBack="True" OnCheckedChanged="chkHeader_CheckedChanged" />
                </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkSelect" runat="server" Height="20px" Width="20px" CssClass="chkSelect" onclick="CheckSelected_Click(this)" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ref No" SortExpression="DC_ Ref No">
                      
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("Ref_No") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                        <ItemStyle Width="130px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText=" Arrival Date" SortExpression="Arrival_Date">
                       
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("Arrival_Date", "{0:dd-MMM-yyyy}") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                        <ControlStyle Width="95px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Item Name" SortExpression=" Item_Name">
                       
                        <ItemTemplate>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("Item_Name") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                         <ControlStyle Width="200px" />
                    </asp:TemplateField>
                    
                     <asp:TemplateField HeaderText="HSN Code" >
                       
                        <ItemTemplate>
                            <asp:Label ID="LHSN" runat="server" Text='<%# Bind("HSN_Code") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                         <ControlStyle Width="200px" />
                    </asp:TemplateField>
    
                     <asp:TemplateField HeaderText="Tax Format" >
                       
                        <ItemTemplate>
                            <asp:Label ID="LTaxFormat" runat="server" Text='<%# Bind("Tax_Format") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                         <ControlStyle Width="200px" />
                    </asp:TemplateField>
                    
                     <asp:TemplateField HeaderText="Tax %">
                       
                        <ItemTemplate>
                            <asp:Label ID="LTax" runat="server" Text='<%# Bind("Tax_Perc") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                         <ControlStyle Width="20px" />
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Packing" SortExpression="Packing">
                      
                            <ItemTemplate>
                            <asp:Label ID="LPack" runat="server" Text='<%# Bind("Packing") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                         <ControlStyle Width="100px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="DC Balance Qty"><ItemTemplate>
    <asp:Label ID="LDBQ" runat="server" Text='<%# Bind("BalToRec") %>'></asp:Label>         
                            
    </ItemTemplate>
                        <ItemStyle ForeColor="#FF8000" HorizontalAlign="Center" />
    </asp:TemplateField>
    
    <asp:TemplateField HeaderText="Rate">
    <ItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Rate") %>' contentEditable="false" ValidationGroup="a" Width="40px" Font-Bold="True" Font-Size="10pt"></asp:TextBox>
                        
    </ItemTemplate>
    </asp:TemplateField>
    
                    
                      <asp:TemplateField HeaderText="UOM" SortExpression="UOM">
                      
                        <ItemTemplate>
                            <asp:Label ID="Label10" runat="server" Text='<%# Bind("UOM") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                    </asp:TemplateField>
                    
                    
                  <asp:TemplateField HeaderText="Enter Invoice Quantity">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="LTQ" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
    </asp:TemplateField>
                 
                  
                    <asp:TemplateField HeaderText="Item Amount" SortExpression="Item_Amount">
                      
                        
                        <ItemTemplate>
                            <asp:Label ID="LItemAmount" runat="server" ></asp:Label>
                            <asp:TextBox ID="LCA" runat="server" contentEditable="false"  Width="80px"></asp:TextBox>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    
                     <asp:TemplateField HeaderText="Discount %">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="TDPerc" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
    </asp:TemplateField>
    
     <asp:TemplateField HeaderText="Discount Amount">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="TDAmt" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
    </asp:TemplateField>
                    
    <asp:TemplateField HeaderText="Amount After Discount">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="TAmtAfterDis" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
    </asp:TemplateField>
    
                     <asp:TemplateField HeaderText="CGST Amount">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="TCGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
    </asp:TemplateField>
    
    <asp:TemplateField HeaderText="SGST Amount">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="TSGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
    </asp:TemplateField>
    
    
    <asp:TemplateField HeaderText="IGST Amount">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="TIGST" runat="server" Width="70px"  BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
    </asp:TemplateField>
    
    <asp:TemplateField HeaderText="Total Amount">
                  
                  <ItemTemplate>
                            <asp:TextBox ID="TTotal" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                        </ItemTemplate>
                        <FooterTemplate>
                              <table>
            <tr>
                <td style="width: 100px; height: 20px; text-align: left">
                    <span style="color: blue">
                    Item Total Amount</span></td>
                <td style="width: 100px; height: 20px">
                    <asp:TextBox ID="AmountTotal" runat="server" contentEditable="false" Font-Bold="True" ForeColor="Blue"
                        Width="80px" Font-Names="Palatino Linotype" Font-Size="10pt"></asp:TextBox></td>
                <td style="width: 100px; height: 20px">
                </td>
            </tr>
                                  <tr>
                                      <td style="width: 100px; height: 20px; text-align: left">
                                          Forwarding</td>
                                      <td style="width: 100px; height: 20px">
    <asp:TextBox ID="Famt" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                      <td style="width: 100px; height: 20px">
                                      </td>
                                  </tr>
            <tr>
                <td style="width: 100px; height: 20px; text-align: left;">
                    Packing</td>
                <td style="width: 100px; height: 20px;">
    <asp:TextBox ID="Pack" runat="server" CssClass="textSelector"  ValidationGroup="a" Width="80px"></asp:TextBox></td>
                <td style="width: 100px; height: 20px;">
                    </td>
            </tr>
                                  <tr>
                                      <td style="width: 100px; height: 26px; text-align: center">
                                          Forwarding + Packing Tax</td>
                                      <td style="width: 100px; height: 26px">
                                          <asp:TextBox ID="TextBox4" runat="server" CssClass="textSelector" ValidationGroup="a"
                                              Width="80px"></asp:TextBox></td>
                                      <td style="width: 100px; height: 26px">
                    <asp:DropDownList
                                     ID="D1" runat="server" DataSourceID="tax" CssClass="textSelector"  DataTextField="CodeName"
                                     DataValueField="CodeName" AppendDataBoundItems="True" AutoPostBack="True" 
                                     OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
                                     <asp:ListItem Selected="True">Select</asp:ListItem>
    <asp:ListItem 5% Tax</asp:ListItem>
    <asp:ListItem 10% Tax</asp:ListItem>
    <asp:ListItem 20% Tax</asp:ListItem>
                                 </asp:DropDownList></td>
                                  </tr>
            <tr>
                <td style="width: 100px; text-align: left; height: 24px;">
                    MIS</td>
                <td style="width: 100px; height: 24px;">
    <asp:TextBox ID="MIS" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                <td style="width: 100px; height: 24px;">
    </td>
            </tr>
                                  <tr>
                                      <td style="width: 100px; text-align: left">
    Round Off</td>
                                      <td style="width: 100px">
    <asp:TextBox ID="Roff" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                      <td style="width: 100px">
                                      </td>
                                  </tr>
                                  <tr>
                                      <td style="width: 100px; text-align: left">
                                          <span style="font-size: 14pt; color: mediumseagreen">
                    G.Total</span></td>
                                      <td style="width: 100px">
    
    
     
    
      <asp:TextBox ID="GT" runat="server" contentEditable="false" Font-Names="Palatino Linotype" Width="80px" Font-Size="10pt" style="vertical-align: middle; text-align: right" 
       ForeColor="Black"></asp:TextBox></td>
                                      <td style="width: 100px">
                                      </td>
                                  </tr>
        </table>
        
        
                        </FooterTemplate>
    </asp:TemplateField>
    
                       <asp:TemplateField HeaderText="Batch Number" >
                       
                        <ItemTemplate>
                            <asp:TextBox ID="LBatchNo" runat="server"></asp:TextBox>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="Teal" />
                    </asp:TemplateField>
                    
                </Columns>
            </asp:GridView>
    

    I need to calculate using jquery or JavaScript without postback 

    My gridview data is below i need like this below

    Monday, July 24, 2017 7:19 PM

Answers

  • User-707554951 posted

    Hi  asp.ambur

    Following code for your reference:

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                //get Forwarding Packing Tax
                $("select[class='textSelector']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();         
                    var gtotal = parseFloat(itemtotalamout);
                    var packingtax = $("select[class='textSelector'] option:selected").text();
                   var floattaxsting= packingtax.split(" ")[0]
                   var floattax = parseFloat(floattaxsting) / 100;
                   var pack = $("input[id$='Pack']").val();
                   var msi = $("input[id$='MIS']").val();
                   var roundoff = $("input[id$='Roff']").val();
                   var Forwarding = $("input[id$='Famt']").val();
                   if (pack =="") {
                       Fpt = parseInt(Forwarding) * floattax;
                       $("input[id$='TextBox4']").val(Math.round(Fpt * 100) / 100);
                   }
                   if (Forwarding == "") {
                       var Fpt = parseInt(pack) * floattax;
                       $("input[id$='TextBox4']").val(Math.round(Fpt * 100) / 100);
                   }
                   if (pack != "" && Forwarding != "") {
                       var Fpt = (parseInt(pack) + parseInt(Forwarding)) * floattax;
                       $("input[id$='TextBox4']").val(Math.round(Fpt * 100) / 100);
                   }
                   if (pack == "" && Forwarding == "") {
                       $("input[id$='TextBox4']").val(" ");
                   }
                   var fpt = $("input[id$='TextBox4']").val();
                   if (Forwarding != "") {
                       gtotal += parseInt(Forwarding);                  
                   }
                   if (pack != "") {
                       gtotal += parseInt(pack);;
                   }
                   if (fpt != "") {
                       gtotal += parseFloat(fpt);
                   }
                   if (msi != "") {
                       gtotal += parseInt(msi);
                   }
                   if (roundoff != "") {
                       gtotal += parseFloat(roundoff);
                   }
                   var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                   $("input[id$='GT']").val(totalint);
                })
                //get G.Total      
    
                $("input[id$='MIS']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $(this).val();
                    var gtotal = parseFloat(itemtotalamout);
                    if (Forwarding != "") {
                        gtotal += parseInt(Forwarding);
                    }
                    if (pack != "") {
                        gtotal += parseInt(pack);
                    }
                    if (fpt != "") {
                        gtotal += parseFloat(fpt);
                    }
                    if (msi != "") {
                        gtotal += parseInt(msi);
                    }             
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);
                })
                $("input[id$='Roff']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();              
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $("input[id$='MIS']").val();
                    var gtotal = parseFloat(itemtotalamout);
                    if (Forwarding != "") {                              
                        gtotal += parseInt(Forwarding);
                    }
                    if (pack != "") {
                        gtotal += parseInt(pack);
                    }
                    if (fpt != "") {
                        gtotal += parseFloat(fpt);
                    }
                    
                    if (msi != "") {
                        gtotal += parseInt(msi);
                    }         
                        gtotal += parseFloat($(this).val());
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);
                  //  var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());               
                })
    
                $("input[id*='LTQ']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var Rate = $(this).parent().prev().prev().find("input[id*='TextBox1']").val();
                            var ItemAmount = parseInt(Rate) * parseInt($(this).val());
                            var ItemAmounttxt =   $(this).parent().next().find("input[id*='LCA']");
                            ItemAmounttxt.val(ItemAmount);
                        }
                    })
                })
    
                $("input[id*='TDPerc']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var InvoiQuantity = $(this).parent().prev().prev().find("input[id*='LTQ']").val();
                            // alert(InvoiQuantity);
                            var Discount = $(this).val();
                            var ItemAmount = $(this).parent().prev().find("input[id*='LCA']").val();
                            // alert(ItemAmount);
                            var DiscountAmounttxt = $(this).parent().next().find("input[id*='TDAmt']").val(InvoiQuantity);
                            var AmountAfterDiscount = parseInt(ItemAmount) - parseInt(InvoiQuantity);
                            // alert(AmountAfterDiscount);
                            var AmountAfterDiscounttxt = $(this).parent().next().next().find("input[id*='TAmtAfterDis']").val(AmountAfterDiscount);
                            var TaxFormatval = $(this).parent().prevAll().eq(6).find("span[id*='LTaxFormat']").text();
                            //  alert(TaxFormatval);
                            if (TaxFormatval == "CGST+SGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                // alert(Tax)
                                var taxdividebytwo = parseFloat(Tax) / 200;
                                // alert(taxdividebytwo);
                                var SGSTCGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(SGSTCGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val("0");
                                var TotalAmount = AmountAfterDiscount + SGSTCGSTval * 2;
                                // alert(TotalAmount);
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                 //Item Total Amount
                                var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                           
                                 var spitid = id.split('_');                         
                                var intidindex = parseInt(spitid[2])                                              
                                if (intidindex == 0) {
                                    $("input[id$='AmountTotal']").val(TotalAmount);
                                    $("input[id$='GT']").val(TotalAmount);
                                }
                                else {
                                    for (var i = intidindex - 1; i >= 0; i--) {                                                     
                                       var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat( pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);
                                        $("input[id$='GT']").val(TotalAmount);
                                    }
                                }                                                      
                            }
                            if (TaxFormatval == "IGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                var taxdividebytwo = parseFloat(Tax) / 100;
                                var IGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(IGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val("0");
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val("0");
                                //1. IGST set 10%  it ahs to show 284.85 
                                //$(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(3));
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(4));
                                var TotalAmount = AmountAfterDiscount + IGSTval;               
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                //Item Total Amount
                                var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                         
                                var spitid = id.split('_');                         
                                var intidindex = parseInt(spitid[2])                           
                                    for (var i = intidindex - 1; i >= 0; i--) {
                                        var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat(pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);
                                        $("input[id$='GT']").val(TotalAmount);
                                }                         
                            }
                        }
                    })
                })
            })
        </script>

    Output:

    Best regards

    Cathy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 1, 2017 5:49 AM

All replies

  • User-1590246810 posted

    Which fields, you want to calculate from client side.? 

    Wednesday, July 26, 2017 5:30 AM
  • User-707554951 posted

    Hi asp.ambur,

    Based on your needs, I make  an working sample for you.

    You could do some change based on your concrete needs

     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $("input[id*='LTQ']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var Rate = $(this).parent().prev().prev().find("input[id*='TextBox1']").val();
              
                            var ItemAmount = parseInt(Rate) * parseInt($(this).val());
                     
                            var ItemAmounttxt =   $(this).parent().next().find("input[id*='LCA']");
                            ItemAmounttxt.val(ItemAmount);
                        }
    
                    })
                })
    
                $("input[id*='TDPerc']").each(function () {
    
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var InvoiQuantity = $(this).parent().prev().prev().find("input[id*='LTQ']").val();
                         
                            var Discount = $(this).val();
                            var ItemAmount = $(this).parent().prev().find("input[id*='LCA']").val();
                           
                            var DiscountAmounttxt = $(this).parent().next().find("input[id*='TDAmt']").val(InvoiQuantity);
                            var AmountAfterDiscount = parseInt(ItemAmount) - parseInt(InvoiQuantity);
                           
                            var AmountAfterDiscounttxt = $(this).parent().next().next().find("input[id*='TAmtAfterDis']").val(AmountAfterDiscount);
                            var TaxFormatval = $(this).parent().prevAll().eq(6).find("span[id*='LTaxFormat']").text();
                       
                            if (TaxFormatval == "CGST+SGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                             
                                var taxdividebytwo = parseFloat(Tax) / 200;
                          
                                var SGSTCGSTval = AmountAfterDiscount * taxdividebytwo;
                    
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val("0");
                                var TotalAmount = AmountAfterDiscount + SGSTCGSTval * 2;
                                
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                            }
                            if (TaxFormatval == "IGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                var taxdividebytwo = parseFloat(Tax) / 100;
                                var IGSTval = AmountAfterDiscount * taxdividebytwo;
                          
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val("0");
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val("0");
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(3));
                                var TotalAmount = AmountAfterDiscount + IGSTval;
                                
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                            }
                        }
                    })
                })
            })
        </script>
    
      <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" Width="700">
                    <Columns>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                <asp:CheckBox ID="chkHeader" runat="server" Height="20px" Width="20px" CssClass="chkHeader" AutoPostBack="True" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkSelect" runat="server" Height="20px" Width="20px" CssClass="chkSelect" onclick="CheckSelected_Click(this)" />
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Ref No" SortExpression="DC_ Ref No">
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Ref_No") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ItemStyle Width="130px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText=" Arrival Date" SortExpression="Arrival_Date">
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("Arrival_Date", "{0:dd-MMM-yyyy}") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="95px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Item Name" SortExpression=" Item_Name">
                            <ItemTemplate>
                                <asp:Label ID="Label4" runat="server" Text='<%# Bind("Item_Name") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="HSN Code">
                            <ItemTemplate>
                                <asp:Label ID="LHSN" runat="server" Text='<%# Bind("HSN_Code") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Tax Format">
                            <ItemTemplate>
                                <asp:Label ID="LTaxFormat" runat="server" Text='<%# Bind("Tax_Format") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Tax %">
                            <ItemTemplate>
                                <asp:Label ID="LTax" runat="server" Text='<%# Bind("Tax_Perc") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="20px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Packing" SortExpression="Packing">
                            <ItemTemplate>
                                <asp:Label ID="LPack" runat="server" Text='<%# Bind("Packing") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="100px" />
                        </asp:TemplateField>
    
    <%--                    <asp:TemplateField HeaderText="DC Balance Qty">
                            <ItemTemplate>
                                <asp:Label ID="LDBQ" runat="server" Text='<%# Bind("BalToRec") %>'></asp:Label>
                            </ItemTemplate>
                            <ItemStyle ForeColor="#FF8000" HorizontalAlign="Center" />
                        </asp:TemplateField>--%>
    
                        <asp:TemplateField HeaderText="Rate">
                            <ItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Rate") %>' contentEditable="false" ValidationGroup="a" Width="40px" Font-Bold="True" Font-Size="10pt"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
    
                        <asp:TemplateField HeaderText="UOM" SortExpression="UOM">
                            <ItemTemplate>
                                <asp:Label ID="Label10" runat="server" Text='<%# Bind("UOM") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Enter Invoice Quantity">
                            <ItemTemplate>
                                <asp:TextBox ID="LTQ" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Item Amount" SortExpression="Item_Amount">
                            <ItemTemplate>
                                <asp:Label ID="LItemAmount" runat="server"></asp:Label>
                                <asp:TextBox ID="LCA" runat="server" contentEditable="false" Width="80px"></asp:TextBox>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Discount %">
                            <ItemTemplate>
                                <asp:TextBox ID="TDPerc" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Discount Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TDAmt" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Amount After Discount">
                            <ItemTemplate>
                                <asp:TextBox ID="TAmtAfterDis" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="CGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TCGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="SGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TSGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
    
                        <asp:TemplateField HeaderText="IGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TIGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Total Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TTotal" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                            <FooterTemplate>
                                <table>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left">
                                            <span style="color: blue">Item Total Amount</span></td>
                                        <td style="width: 100px; height: 20px">
                                            <asp:TextBox ID="AmountTotal" runat="server" contentEditable="false" Font-Bold="True" ForeColor="Blue"
                                                Width="80px" Font-Names="Palatino Linotype" Font-Size="10pt"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left">Forwarding</td>
                                        <td style="width: 100px; height: 20px">
                                            <asp:TextBox ID="Famt" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left;">Packing</td>
                                        <td style="width: 100px; height: 20px;">
                                            <asp:TextBox ID="Pack" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px;"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 26px; text-align: center">Forwarding + Packing Tax</td>
                                        <td style="width: 100px; height: 26px">
                                            <asp:TextBox ID="TextBox4" runat="server" CssClass="textSelector" ValidationGroup="a"
                                                Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 26px">
                                            <asp:DropDownList
                                                ID="D1" runat="server"  CssClass="textSelector" DataTextField="CodeName"
                                                DataValueField="CodeName" AppendDataBoundItems="True" AutoPostBack="True">
                                                <asp:ListItem Selected="True">Select</asp:ListItem>
                                                <asp:ListItem>5% Tax</asp:ListItem>
                                                <asp:ListItem>10% Tax</asp:ListItem>
                                                <asp:ListItem>20% Tax</asp:ListItem>
                                            </asp:DropDownList></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left; height: 24px;">MIS</td>
                                        <td style="width: 100px; height: 24px;">
                                            <asp:TextBox ID="MIS" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 24px;"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left">Round Off</td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="Roff" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left">
                                            <span style="font-size: 14pt; color: mediumseagreen">G.Total</span></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="GT" runat="server" contentEditable="false" Font-Names="Palatino Linotype" Width="80px" Font-Size="10pt" Style="vertical-align: middle; text-align: right"
                                                ForeColor="Black"></asp:TextBox></td>
                                        <td style="width: 100px"></td>
                                    </tr>
                                </table>
                            </FooterTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Batch Number">
                            <ItemTemplate>
                                <asp:TextBox ID="LBatchNo" runat="server"></asp:TextBox>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                        </asp:TemplateField>
    
                    </Columns>
                </asp:GridView>

    Output:

    Best regards

    Cathy

    Wednesday, July 26, 2017 5:34 AM
  • User2033107836 posted

    Hello Cathy 

    Thanks For Your Code

    I want code for final amount, Forwarding, Packing, MIS, RoundOff, forwarding + packing tax

    See the screenshot below

    Wednesday, July 26, 2017 9:12 AM
  • User-707554951 posted

    Hi asp.ambur,

    Working code as below :

    Note: do change by yourself based on your concrete needs(something as decimals)

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                //get Forwarding Packing Tax
                $("select[class='textSelector']").change(function () {
                    var packingtax = $("select[class='textSelector'] option:selected").text();
                   var floattaxsting= packingtax.split(" ")[0]
                   var floattax = parseFloat(floattaxsting) / 100;
                   var pack = $("input[id$='Pack']").val();
                   var Forwarding = $("input[id$='Famt']").val();
                   var Fpt = (parseInt(pack) + parseInt(Forwarding)) * floattax
                   $("input[id$='TextBox4']").val(Fpt);
                })
                //get G.Total
                $("input[id$='Roff']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();              
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $("input[id$='MIS']").val();
                    var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);       
                })
                $("input[id*='LTQ']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var Rate = $(this).parent().prev().prev().find("input[id*='TextBox1']").val();
                            var ItemAmount = parseInt(Rate) * parseInt($(this).val());
                            var ItemAmounttxt =   $(this).parent().next().find("input[id*='LCA']");
                            ItemAmounttxt.val(ItemAmount);
                        }
                    })
                })
    
                $("input[id*='TDPerc']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var InvoiQuantity = $(this).parent().prev().prev().find("input[id*='LTQ']").val();
                            // alert(InvoiQuantity);
                            var Discount = $(this).val();
                            var ItemAmount = $(this).parent().prev().find("input[id*='LCA']").val();
                            // alert(ItemAmount);
                            var DiscountAmounttxt = $(this).parent().next().find("input[id*='TDAmt']").val(InvoiQuantity);
                            var AmountAfterDiscount = parseInt(ItemAmount) - parseInt(InvoiQuantity);
                            // alert(AmountAfterDiscount);
                            var AmountAfterDiscounttxt = $(this).parent().next().next().find("input[id*='TAmtAfterDis']").val(AmountAfterDiscount);
                            var TaxFormatval = $(this).parent().prevAll().eq(6).find("span[id*='LTaxFormat']").text();
                            //  alert(TaxFormatval);
                            if (TaxFormatval == "CGST+SGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                // alert(Tax)
                                var taxdividebytwo = parseFloat(Tax) / 200;
                                // alert(taxdividebytwo);
                                var SGSTCGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(SGSTCGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val("0");
                                var TotalAmount = AmountAfterDiscount + SGSTCGSTval * 2;
                                // alert(TotalAmount);
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                 //Item Total Amount
                                var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                           
                                 var spitid = id.split('_');                         
                                var intidindex = parseInt(spitid[2])                                              
                                if (intidindex == 0) {
                                    $("input[id$='AmountTotal']").val(TotalAmount);
                                }
                                else {
                                    for (var i = intidindex - 1; i >= 0; i--) {                                                     
                                       var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat( pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);
                                    }
                                }                                                      
                            }
                            if (TaxFormatval == "IGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                var taxdividebytwo = parseFloat(Tax) / 100;
                                var IGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(IGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val("0");
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val("0");
                                //1. IGST set 10%  it ahs to show 284.85 
                                //$(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(3));
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(4));
                                var TotalAmount = AmountAfterDiscount + IGSTval;               
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                //Item Total Amount
                                var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                         
                                var spitid = id.split('_');                         
                                var intidindex = parseInt(spitid[2])                           
                                    for (var i = intidindex - 1; i >= 0; i--) {
                                        var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat(pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);                                
                                }                         
                            }
                        }
                    })
                })
            })
        </script>
    
     <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" Width="700" ShowFooter="true">
                    <Columns>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                <asp:CheckBox ID="chkHeader" runat="server" Height="20px" Width="20px" CssClass="chkHeader" AutoPostBack="True" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkSelect" runat="server" Height="20px" Width="20px" CssClass="chkSelect" onclick="CheckSelected_Click(this)" />
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Ref No" SortExpression="DC_ Ref No">
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Ref_No") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ItemStyle Width="130px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText=" Arrival Date" SortExpression="Arrival_Date">
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("Arrival_Date", "{0:dd-MMM-yyyy}") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="95px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Item Name" SortExpression=" Item_Name">
                            <ItemTemplate>
                                <asp:Label ID="Label4" runat="server" Text='<%# Bind("Item_Name") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="HSN Code">
                            <ItemTemplate>
                                <asp:Label ID="LHSN" runat="server" Text='<%# Bind("HSN_Code") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Tax Format">
                            <ItemTemplate>
                                <asp:Label ID="LTaxFormat" runat="server" Text='<%# Bind("Tax_Format") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Tax %">
                            <ItemTemplate>
                                <asp:Label ID="LTax" runat="server" Text='<%# Bind("Tax_Perc") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="20px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Packing" SortExpression="Packing">
                            <ItemTemplate>
                                <asp:Label ID="LPack" runat="server" Text='<%# Bind("Packing") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="100px" />
                        </asp:TemplateField>
    
    <%--                    <asp:TemplateField HeaderText="DC Balance Qty">
                            <ItemTemplate>
                                <asp:Label ID="LDBQ" runat="server" Text='<%# Bind("BalToRec") %>'></asp:Label>
                            </ItemTemplate>
                            <ItemStyle ForeColor="#FF8000" HorizontalAlign="Center" />
                        </asp:TemplateField>--%>
    
                        <asp:TemplateField HeaderText="Rate">
                            <ItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Rate") %>' contentEditable="false" ValidationGroup="a" Width="40px" Font-Bold="True" Font-Size="10pt"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
    
                        <asp:TemplateField HeaderText="UOM" SortExpression="UOM">
                            <ItemTemplate>
                                <asp:Label ID="Label10" runat="server" Text='<%# Bind("UOM") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Enter Invoice Quantity">
                            <ItemTemplate>
                                <asp:TextBox ID="LTQ" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Item Amount" SortExpression="Item_Amount">
                            <ItemTemplate>
                                <asp:Label ID="LItemAmount" runat="server"></asp:Label>
                                <asp:TextBox ID="LCA" runat="server" contentEditable="false" Width="80px"></asp:TextBox>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Discount %">
                            <ItemTemplate>
                                <asp:TextBox ID="TDPerc" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Discount Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TDAmt" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Amount After Discount">
                            <ItemTemplate>
                                <asp:TextBox ID="TAmtAfterDis" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="CGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TCGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="SGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TSGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
    
                        <asp:TemplateField HeaderText="IGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TIGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Total Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TTotal" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                            <FooterTemplate>
                                <table>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left">
                                            <span style="color: blue">Item Total Amount</span></td>
                                        <td style="width: 100px; height: 20px">
                                            <asp:TextBox ID="AmountTotal" runat="server" contentEditable="false" Font-Bold="True" ForeColor="Blue"
                                                Width="80px" Font-Names="Palatino Linotype" Font-Size="10pt"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left">Forwarding</td>
                                        <td style="width: 100px; height: 20px">
                                            <asp:TextBox ID="Famt" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left;">Packing</td>
                                        <td style="width: 100px; height: 20px;">
                                            <asp:TextBox ID="Pack" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px;"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 26px; text-align: center">Forwarding + Packing Tax</td>
                                        <td style="width: 100px; height: 26px">
                                            <asp:TextBox ID="TextBox4" runat="server" CssClass="textSelector" ValidationGroup="a"
                                                Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 26px">
                                            <asp:DropDownList
                                                ID="D1" runat="server"  CssClass="textSelector" >
                                                <asp:ListItem >Select</asp:ListItem>
                                                <asp:ListItem>5% Tax</asp:ListItem>
                                                <asp:ListItem >10% Tax</asp:ListItem>
                                                <asp:ListItem>20% Tax</asp:ListItem>
                                            </asp:DropDownList></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left; height: 24px;">MIS</td>
                                        <td style="width: 100px; height: 24px;">
                                            <asp:TextBox ID="MIS" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 24px;"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left">Round Off</td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="Roff" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left">
                                            <span style="font-size: 14pt; color: mediumseagreen">G.Total</span></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="GT" runat="server" contentEditable="false" Font-Names="Palatino Linotype" Width="80px" Font-Size="10pt" Style="vertical-align: middle; text-align: right"
                                                ForeColor="Black"></asp:TextBox></td>
                                        <td style="width: 100px"></td>
                                    </tr>
                                </table>
                            </FooterTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Batch Number">
                            <ItemTemplate>
                                <asp:TextBox ID="LBatchNo" runat="server"></asp:TextBox>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                        </asp:TemplateField>
    
                    </Columns>
                </asp:GridView>

    Output:

    Best regards

    Cathy

    Thursday, July 27, 2017 3:23 AM
  • User2033107836 posted

    Hello Cathy

    I used IGST to test your new code

    var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id'); 
    alert(id); 
    var spitid = id.split('_'); 
    alert(spitid); 
    var intidindex = parseInt(spitid[2]) 
    alert(intidindex);
    
    



    On first alert its showing :ct100_ContentPlaceHolder1_GridView2_ct102_TTotal

    On second alert its showing : ct100,ContentPlaceHolder1,GridView2,ct102,TTotal

    On Third alert its showing :  NaN

    total not coming why

    Thursday, July 27, 2017 6:14 AM
  • User-707554951 posted

    Hi asp.ambur,

    From your description, it seems that you used master page, you put gridview in contend page.

    spitid[2] return "GridView2" when you using parseInt,If the parameter in this function cannot be converted to a number, parseInt() returns NaN.

    So, I suggest you change selection in jquery code based on your code.

    Best regards

    Cathy

    Thursday, July 27, 2017 6:56 AM
  • User2033107836 posted

    Yes Sir

    Your Right im using master_page yes my gridview is in contend page  how to do please give me code i will replace

    Thanks in advance

    Thursday, July 27, 2017 7:05 AM
  • User-707554951 posted

    Hi asp.ambur,

    how you put gridview.

    Please give ive me the code you use in master page and content page.

    Best regards

    Cathy

    Thursday, July 27, 2017 7:19 AM
  • User2033107836 posted

    My master page code

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
    <!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 id="Head1" runat="server">
        <title>Master Page</title>
    <script src="jquery-3.2.1.min.js"></script>
    
    </head> 
    
    <body onload="Maximise()">			
        <form id="form1" runat="server" >
    
        <div>
     <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
      </asp:ContentPlaceHolder>
    </div>
            
    
    
            
    </form>
      
    </body>
    </html>

    My content page code of gridview

    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="NewInvoice.aspx.cs" Inherits="Invoice" %>
    
    <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Namespace="System.Web.UI" TagPrefix="asp" %>
    
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    
    </asp:Content>

    Thursday, July 27, 2017 8:15 AM
  • User2033107836 posted

    I Checked in my source its id is like this

    ct100_ContentPlaceHolder1_GridView2_ct102_TTotal

    Thursday, July 27, 2017 9:56 AM
  • User2033107836 posted

    Hello Cathy 

    Is any other method or code to do footer calculation...

    Thursday, July 27, 2017 12:11 PM
  • User2033107836 posted
    I tried this below method not working
    var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');
    var spitid = id.split('_');
    var intidindex = parseInt(spitid[2])
    if (intidindex == 0) {
    $("input[id$='AmountTotal']").val(TotalAmount);
    }
    else {
    for (var i = intidindex - 1; i >= 0; i--) {
    var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
    TotalAmount += parseFloat( pretotal);
    $("input[id$='AmountTotal']").val(TotalAmount);
    }
    }
    Any other methods pls give me to code
    Friday, July 28, 2017 8:36 AM
  • User-707554951 posted

    Hi asp.ambur,

    Add ClientIDMode="Static" to 'TTotal' TextBox as following.

        <asp:TextBox ID="TTotal" ClientIDMode="Static" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>

    Then use the following code:

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                //get Forwarding Packing Tax
                $("select[class='textSelector']").change(function () {
                    var packingtax = $("select[class='textSelector'] option:selected").text();
                   var floattaxsting= packingtax.split(" ")[0]
                   var floattax = parseFloat(floattaxsting) / 100;
                   var pack = $("input[id$='Pack']").val();
                   var Forwarding = $("input[id$='Famt']").val();
                   var Fpt = (parseInt(pack) + parseInt(Forwarding)) * floattax
                   $("input[id$='TextBox4']").val(Fpt);
                })
                //get G.Total
                $("input[id$='Roff']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();              
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $("input[id$='MIS']").val();
                    var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);       
                })
                $("input[id*='LTQ']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var Rate = $(this).parent().prev().prev().find("input[id*='TextBox1']").val();
                            var ItemAmount = parseInt(Rate) * parseInt($(this).val());
                            var ItemAmounttxt =   $(this).parent().next().find("input[id*='LCA']");
                            ItemAmounttxt.val(ItemAmount);
                        }
                    })
                })
    
                $("input[id*='TDPerc']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var InvoiQuantity = $(this).parent().prev().prev().find("input[id*='LTQ']").val();
                            // alert(InvoiQuantity);
                            var Discount = $(this).val();
                            var ItemAmount = $(this).parent().prev().find("input[id*='LCA']").val();
                            // alert(ItemAmount);
                            var DiscountAmounttxt = $(this).parent().next().find("input[id*='TDAmt']").val(InvoiQuantity);
                            var AmountAfterDiscount = parseInt(ItemAmount) - parseInt(InvoiQuantity);
                            // alert(AmountAfterDiscount);
                            var AmountAfterDiscounttxt = $(this).parent().next().next().find("input[id*='TAmtAfterDis']").val(AmountAfterDiscount);
                            var TaxFormatval = $(this).parent().prevAll().eq(6).find("span[id*='LTaxFormat']").text();
                            //  alert(TaxFormatval);
                            if (TaxFormatval == "CGST+SGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                // alert(Tax)
                                var taxdividebytwo = parseFloat(Tax) / 200;
                                // alert(taxdividebytwo);
                                var SGSTCGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(SGSTCGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val("0");
                                var TotalAmount = AmountAfterDiscount + SGSTCGSTval * 2;
                                // alert(TotalAmount);
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                //Item Total Amount
                           
                                //var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');  
                                var id = $(this).parent().parent().index();
                                //var spitid = id.split('_');
                                var intidindex = parseInt(id)-1
                                if (intidindex == 0) {
                                    $("input[id$='AmountTotal']").val(TotalAmount);
                                }
                                else {
                                    for (var i = intidindex - 1; i >= 0; i--) {                                                     
                                       var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat( pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);
                                    }
                                }                                                      
                            }
                            if (TaxFormatval == "IGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                var taxdividebytwo = parseFloat(Tax) / 100;
                                var IGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(IGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val("0");
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val("0");
                                //1. IGST set 10%  it ahs to show 284.85 
                                //$(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(3));
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(4));
                                var TotalAmount = AmountAfterDiscount + IGSTval;               
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                //Item Total Amount
                                //var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                         
                                var id = $(this).parent().parent().index();
                                //var spitid = id.split('_');
                                var intidindex = parseInt(id) - 1                                           
                                    for (var i = intidindex - 1; i >= 0; i--) {
                                        var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat(pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);                                
                                }                         
                            }
                        }
                    })
                })
            })
        </script>

    Best regards

    Cathy

    Friday, July 28, 2017 8:59 AM
  • User2033107836 posted

    Hello Mr.Cathy 

    I added alert for this below code

     var id = $(this).parent().parent().index();
                                alert(id);
                                //var spitid = id.split('_');
                                var intidindex = parseInt(id) - 1      
                                         alert(intidindex); 

    its showing first alert 1 and second alert 0 and  total not showing..?

    Friday, July 28, 2017 9:13 AM
  • User2033107836 posted

    CGST + SGST works fine..

    IGST not working why?

    Friday, July 28, 2017 9:19 AM
  • User-707554951 posted

    Hi asp.ambur

    Full code i used to test as below.

    I hope you could carefully and do understanding:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Test/masterpage.Master" AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs" Inherits="Case_Test.Test.WebForm6" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                //get Forwarding Packing Tax
                $("select[class='textSelector']").change(function () {
                    var packingtax = $("select[class='textSelector'] option:selected").text();
                   var floattaxsting= packingtax.split(" ")[0]
                   var floattax = parseFloat(floattaxsting) / 100;
                   var pack = $("input[id$='Pack']").val();
                   var Forwarding = $("input[id$='Famt']").val();
                   var Fpt = (parseInt(pack) + parseInt(Forwarding)) * floattax
                   $("input[id$='TextBox4']").val(Fpt);
                })
                //get G.Total
                $("input[id$='Roff']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();              
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $("input[id$='MIS']").val();
                    var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);       
                })
                $("input[id*='LTQ']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var Rate = $(this).parent().prev().prev().find("input[id*='TextBox1']").val();
                            var ItemAmount = parseInt(Rate) * parseInt($(this).val());
                            var ItemAmounttxt =   $(this).parent().next().find("input[id*='LCA']");
                            ItemAmounttxt.val(ItemAmount);
                        }
                    })
                })
    
                $("input[id*='TDPerc']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var InvoiQuantity = $(this).parent().prev().prev().find("input[id*='LTQ']").val();
                            // alert(InvoiQuantity);
                            var Discount = $(this).val();
                            var ItemAmount = $(this).parent().prev().find("input[id*='LCA']").val();
                            // alert(ItemAmount);
                            var DiscountAmounttxt = $(this).parent().next().find("input[id*='TDAmt']").val(InvoiQuantity);
                            var AmountAfterDiscount = parseInt(ItemAmount) - parseInt(InvoiQuantity);
                            // alert(AmountAfterDiscount);
                            var AmountAfterDiscounttxt = $(this).parent().next().next().find("input[id*='TAmtAfterDis']").val(AmountAfterDiscount);
                            var TaxFormatval = $(this).parent().prevAll().eq(6).find("span[id*='LTaxFormat']").text();
                            //  alert(TaxFormatval);
                            if (TaxFormatval == "CGST+SGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                // alert(Tax)
                                var taxdividebytwo = parseFloat(Tax) / 200;
                                // alert(taxdividebytwo);
                                var SGSTCGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(SGSTCGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val("0");
                                var TotalAmount = AmountAfterDiscount + SGSTCGSTval * 2;
                                // alert(TotalAmount);
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                //Item Total Amount
                           
                                //var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');  
                                var id = $(this).parent().parent().index();
                                //var spitid = id.split('_');
                                var intidindex = parseInt(id)-1
                                if (intidindex == 0) {
                                    $("input[id$='AmountTotal']").val(TotalAmount);
                                }
                                else {
                                    for (var i = intidindex - 1; i >= 0; i--) {                                                     
                                       var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat( pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);
                                    }
                                }                                                      
                            }
                            if (TaxFormatval == "IGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                var taxdividebytwo = parseFloat(Tax) / 100;
                                var IGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(IGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val("0");
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val("0");
                                //1. IGST set 10%  it ahs to show 284.85 
                                //$(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(3));
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(4));
                                var TotalAmount = AmountAfterDiscount + IGSTval;               
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                //Item Total Amount
                                //var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                         
                                var id = $(this).parent().parent().index();
                                //var spitid = id.split('_');
                                var intidindex = parseInt(id) - 1                                           
                                    for (var i = intidindex - 1; i >= 0; i--) {
                                        var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat(pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);                                
                                }                         
                            }
                        }
                    })
                })
            })
        </script>
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
         <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" Width="700" ShowFooter="true" >
                    <Columns>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                <asp:CheckBox ID="chkHeader" runat="server" Height="20px" Width="20px" CssClass="chkHeader" AutoPostBack="True" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkSelect" runat="server" Height="20px" Width="20px" CssClass="chkSelect" onclick="CheckSelected_Click(this)" />
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Ref No" SortExpression="DC_ Ref No">
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Ref_No") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ItemStyle Width="130px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText=" Arrival Date" SortExpression="Arrival_Date">
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("Arrival_Date", "{0:dd-MMM-yyyy}") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="95px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Item Name" SortExpression=" Item_Name">
                            <ItemTemplate>
                                <asp:Label ID="Label4" runat="server" Text='<%# Bind("Item_Name") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="HSN Code">
                            <ItemTemplate>
                                <asp:Label ID="LHSN" runat="server" Text='<%# Bind("HSN_Code") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Tax Format">
                            <ItemTemplate>
                                <asp:Label ID="LTaxFormat" runat="server" Text='<%# Bind("Tax_Format") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="200px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Tax %">
                            <ItemTemplate>
                                <asp:Label ID="LTax" runat="server" Text='<%# Bind("Tax_Perc") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="20px" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Packing" SortExpression="Packing">
                            <ItemTemplate>
                                <asp:Label ID="LPack" runat="server" Text='<%# Bind("Packing") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ControlStyle Width="100px" />
                        </asp:TemplateField>
    
    <%--                    <asp:TemplateField HeaderText="DC Balance Qty">
                            <ItemTemplate>
                                <asp:Label ID="LDBQ" runat="server" Text='<%# Bind("BalToRec") %>'></asp:Label>
                            </ItemTemplate>
                            <ItemStyle ForeColor="#FF8000" HorizontalAlign="Center" />
                        </asp:TemplateField>--%>
    
                        <asp:TemplateField HeaderText="Rate">
                            <ItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Rate") %>' contentEditable="false" ValidationGroup="a" Width="40px" Font-Bold="True" Font-Size="10pt"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
    
                        <asp:TemplateField HeaderText="UOM" SortExpression="UOM">
                            <ItemTemplate>
                                <asp:Label ID="Label10" runat="server" Text='<%# Bind("UOM") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Enter Invoice Quantity">
                            <ItemTemplate>
                                <asp:TextBox ID="LTQ" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Item Amount" SortExpression="Item_Amount">
                            <ItemTemplate>
                                <asp:Label ID="LItemAmount" runat="server"></asp:Label>
                                <asp:TextBox ID="LCA" runat="server" contentEditable="false" Width="80px"></asp:TextBox>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Discount %">
                            <ItemTemplate>
                                <asp:TextBox ID="TDPerc" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Discount Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TDAmt" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Amount After Discount">
                            <ItemTemplate>
                                <asp:TextBox ID="TAmtAfterDis" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="CGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TCGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="SGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TSGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
    
                        <asp:TemplateField HeaderText="IGST Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TIGST" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
    
                        <asp:TemplateField HeaderText="Total Amount">
                            <ItemTemplate>
                                <asp:TextBox ID="TTotal" ClientIDMode="Static" runat="server" Width="70px" BorderColor="#0000C0" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="14pt" ForeColor="Purple"></asp:TextBox>
                            </ItemTemplate>
                            <FooterTemplate>
                                <table>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left">
                                            <span style="color: blue">Item Total Amount</span></td>
                                        <td style="width: 100px; height: 20px">
                                            <asp:TextBox ID="AmountTotal" runat="server" contentEditable="false" Font-Bold="True" ForeColor="Blue"
                                                Width="80px" Font-Names="Palatino Linotype" Font-Size="10pt"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left">Forwarding</td>
                                        <td style="width: 100px; height: 20px">
                                            <asp:TextBox ID="Famt" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 20px; text-align: left;">Packing</td>
                                        <td style="width: 100px; height: 20px;">
                                            <asp:TextBox ID="Pack" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 20px;"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 26px; text-align: center">Forwarding + Packing Tax</td>
                                        <td style="width: 100px; height: 26px">
                                            <asp:TextBox ID="TextBox4" runat="server" CssClass="textSelector" ValidationGroup="a"
                                                Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 26px">
                                            <asp:DropDownList
                                                ID="D1" runat="server"  CssClass="textSelector" >
                                                <asp:ListItem >Select</asp:ListItem>
                                                <asp:ListItem>5% Tax</asp:ListItem>
                                                <asp:ListItem >10% Tax</asp:ListItem>
                                                <asp:ListItem>20% Tax</asp:ListItem>
                                            </asp:DropDownList></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left; height: 24px;">MIS</td>
                                        <td style="width: 100px; height: 24px;">
                                            <asp:TextBox ID="MIS" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px; height: 24px;"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left">Round Off</td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="Roff" runat="server" CssClass="textSelector" ValidationGroup="a" Width="80px"></asp:TextBox></td>
                                        <td style="width: 100px"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; text-align: left">
                                            <span style="font-size: 14pt; color: mediumseagreen">G.Total</span></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="GT" runat="server" contentEditable="false" Font-Names="Palatino Linotype" Width="80px" Font-Size="10pt" Style="vertical-align: middle; text-align: right"
                                                ForeColor="Black"></asp:TextBox></td>
                                        <td style="width: 100px"></td>
                                    </tr>
                                </table>
                            </FooterTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Batch Number">
                            <ItemTemplate>
                                <asp:TextBox ID="LBatchNo" runat="server"></asp:TextBox>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="Teal" />
                        </asp:TemplateField>
    
                    </Columns>
                </asp:GridView>
    </asp:Content>

    codebehind:

     protected void Page_Load(object sender, EventArgs e)
            {
                DataTable dt = new DataTable();
                dt.Columns.AddRange(new DataColumn[] { new DataColumn("Ref_No",typeof(string)),
                    new DataColumn("Arrival_Date", typeof(string )),
                    new DataColumn("Item_Name",typeof(string)),
                    new DataColumn("HSN_Code",typeof(string)),
                    new DataColumn("Tax_Format",typeof(string)),
                    new DataColumn("Tax_Perc",typeof(string)),
                    new DataColumn("Packing",typeof(string)),
                    new DataColumn("Rate",typeof(string)),
                    new DataColumn("UOM",typeof(string)),
                });
                dt.Rows.Add("R12", "1-Jun-17", "Apple", "123", "CGST+SGST", "18%", "Seal", "10", "Kg");
                dt.Rows.Add("R12", "1-Jun-17", "Mango", "345", "CGST+SGST", "28%", "Seal", "20", "Kg");
                dt.Rows.Add("R34", "1-Jun-17", "Lemon", "678", "IGST", "18%", "Seal", "5", "Kg");
                dt.Rows.Add("R34", "1-Jun-17", "Banana", "874", "CGST+SGST", "18%", "Seal", "10", "Kg");
                GridView2.DataSource = dt;
                GridView2.DataBind();
            }
        }

    output:

    Best regards

    Cathy

    Friday, July 28, 2017 9:25 AM
  • User2033107836 posted

    Hi Cathy

    Code Works Fine..

     For G.Total i have one issue 

     $("input[id$='Roff']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();              
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $("input[id$='MIS']").val();
                    var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);       
                })

     

    sometimes user will not enter mis, forwarding, packing that time it has to calcualte only given textbox 

    Friday, July 28, 2017 9:33 AM
  • User-707554951 posted

    Hi asp.ambur

    asp.ambur

    sometimes user will not enter mis, forwarding, packing that time it has to calcualte only given textbox 

    For problem above, add if statement to your code, if the value in one of your textbox is null, ignore this when you do calculation for G.Total

    Best regards

    Cathy

    Friday, July 28, 2017 9:40 AM
  • User2033107836 posted

    hello Cathy

    For G.Total i have one issue 

     $("input[id$='Roff']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();              
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $("input[id$='MIS']").val();
                    var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);       
                })

     sometimes user will not enter MIS or Forwarding or Packing or Roundoff that time it has to calculate values and show in G.Total

    Sometimes user will enter Forwarding Or Packing 

    Sometimes user will enter only roundoff

    so G.Total has to calculate if values given else it has to show Amount total in G,Total

    Friday, July 28, 2017 9:41 AM
  • User2033107836 posted
    Hello
    All Issue Resolved Only G.Total Problem

    For G.Total i have one issue

    $("input[id$='Roff']").change(function () {
    var itemtotalamout = $("input[id$='AmountTotal']").val();
    var Forwarding = $("input[id$='Famt']").val();
    var pack = $("input[id$='Pack']").val();
    var fpt = $("input[id$='TextBox4']").val();
    var msi = $("input[id$='MIS']").val();
    var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());
    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
    $("input[id$='GT']").val(totalint);
    })
    sometimes user will not enter MIS or Forwarding or Packing or Roundoff that time it has to calculate values and show in G.Total

    Sometimes user will enter Forwarding Or Packing

    Sometimes user will enter only roundoff

    so G.Total has to calculate if values given else it has to show Amount total in G,Total
    Friday, July 28, 2017 1:44 PM
  • User2033107836 posted

    Hello
    All Issue Resolved Only G.Total Problem

    For G.Total i have one issue 

    $("input[id$='Roff']").change(function () {
    var itemtotalamout = $("input[id$='AmountTotal']").val();
    var Forwarding = $("input[id$='Famt']").val();
    var pack = $("input[id$='Pack']").val(); 
    var fpt = $("input[id$='TextBox4']").val();
    var msi = $("input[id$='MIS']").val();
    var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());
    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
    $("input[id$='GT']").val(totalint); 
    })
    sometimes user will not enter MIS or Forwarding or Packing or Roundoff that time it has to calculate values and show in G.Total

    Sometimes user will enter Forwarding Or Packing 

    Sometimes user will enter only roundoff

    so G.Total has to calculate if values given else it has to show Amount total in G,Total

    Monday, July 31, 2017 8:46 AM
  • User-707554951 posted

    Hi  asp.ambur

    Following code for your reference:

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                //get Forwarding Packing Tax
                $("select[class='textSelector']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();         
                    var gtotal = parseFloat(itemtotalamout);
                    var packingtax = $("select[class='textSelector'] option:selected").text();
                   var floattaxsting= packingtax.split(" ")[0]
                   var floattax = parseFloat(floattaxsting) / 100;
                   var pack = $("input[id$='Pack']").val();
                   var msi = $("input[id$='MIS']").val();
                   var roundoff = $("input[id$='Roff']").val();
                   var Forwarding = $("input[id$='Famt']").val();
                   if (pack =="") {
                       Fpt = parseInt(Forwarding) * floattax;
                       $("input[id$='TextBox4']").val(Math.round(Fpt * 100) / 100);
                   }
                   if (Forwarding == "") {
                       var Fpt = parseInt(pack) * floattax;
                       $("input[id$='TextBox4']").val(Math.round(Fpt * 100) / 100);
                   }
                   if (pack != "" && Forwarding != "") {
                       var Fpt = (parseInt(pack) + parseInt(Forwarding)) * floattax;
                       $("input[id$='TextBox4']").val(Math.round(Fpt * 100) / 100);
                   }
                   if (pack == "" && Forwarding == "") {
                       $("input[id$='TextBox4']").val(" ");
                   }
                   var fpt = $("input[id$='TextBox4']").val();
                   if (Forwarding != "") {
                       gtotal += parseInt(Forwarding);                  
                   }
                   if (pack != "") {
                       gtotal += parseInt(pack);;
                   }
                   if (fpt != "") {
                       gtotal += parseFloat(fpt);
                   }
                   if (msi != "") {
                       gtotal += parseInt(msi);
                   }
                   if (roundoff != "") {
                       gtotal += parseFloat(roundoff);
                   }
                   var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                   $("input[id$='GT']").val(totalint);
                })
                //get G.Total      
    
                $("input[id$='MIS']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $(this).val();
                    var gtotal = parseFloat(itemtotalamout);
                    if (Forwarding != "") {
                        gtotal += parseInt(Forwarding);
                    }
                    if (pack != "") {
                        gtotal += parseInt(pack);
                    }
                    if (fpt != "") {
                        gtotal += parseFloat(fpt);
                    }
                    if (msi != "") {
                        gtotal += parseInt(msi);
                    }             
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);
                })
                $("input[id$='Roff']").change(function () {
                    var itemtotalamout = $("input[id$='AmountTotal']").val();
                    var Forwarding = $("input[id$='Famt']").val();
                    var pack = $("input[id$='Pack']").val();              
                    var fpt = $("input[id$='TextBox4']").val();
                    var msi = $("input[id$='MIS']").val();
                    var gtotal = parseFloat(itemtotalamout);
                    if (Forwarding != "") {                              
                        gtotal += parseInt(Forwarding);
                    }
                    if (pack != "") {
                        gtotal += parseInt(pack);
                    }
                    if (fpt != "") {
                        gtotal += parseFloat(fpt);
                    }
                    
                    if (msi != "") {
                        gtotal += parseInt(msi);
                    }         
                        gtotal += parseFloat($(this).val());
                    var totalint = parseFloat(Math.round(gtotal * 100) / 100);
                    $("input[id$='GT']").val(totalint);
                  //  var gtotal = parseFloat(itemtotalamout) + parseInt(Forwarding) + parseInt(pack) + parseFloat(fpt) + parseInt(msi) + parseFloat($(this).val());               
                })
    
                $("input[id*='LTQ']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var Rate = $(this).parent().prev().prev().find("input[id*='TextBox1']").val();
                            var ItemAmount = parseInt(Rate) * parseInt($(this).val());
                            var ItemAmounttxt =   $(this).parent().next().find("input[id*='LCA']");
                            ItemAmounttxt.val(ItemAmount);
                        }
                    })
                })
    
                $("input[id*='TDPerc']").each(function () {
                    $(this).change(function () {
                        var chkSelectcheckbox = $(this).closest("tr").find("input[type ='checkbox']");
                        if (chkSelectcheckbox.prop('checked')) {
                            var InvoiQuantity = $(this).parent().prev().prev().find("input[id*='LTQ']").val();
                            // alert(InvoiQuantity);
                            var Discount = $(this).val();
                            var ItemAmount = $(this).parent().prev().find("input[id*='LCA']").val();
                            // alert(ItemAmount);
                            var DiscountAmounttxt = $(this).parent().next().find("input[id*='TDAmt']").val(InvoiQuantity);
                            var AmountAfterDiscount = parseInt(ItemAmount) - parseInt(InvoiQuantity);
                            // alert(AmountAfterDiscount);
                            var AmountAfterDiscounttxt = $(this).parent().next().next().find("input[id*='TAmtAfterDis']").val(AmountAfterDiscount);
                            var TaxFormatval = $(this).parent().prevAll().eq(6).find("span[id*='LTaxFormat']").text();
                            //  alert(TaxFormatval);
                            if (TaxFormatval == "CGST+SGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                // alert(Tax)
                                var taxdividebytwo = parseFloat(Tax) / 200;
                                // alert(taxdividebytwo);
                                var SGSTCGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(SGSTCGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val(SGSTCGSTval);
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val("0");
                                var TotalAmount = AmountAfterDiscount + SGSTCGSTval * 2;
                                // alert(TotalAmount);
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                 //Item Total Amount
                                var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                           
                                 var spitid = id.split('_');                         
                                var intidindex = parseInt(spitid[2])                                              
                                if (intidindex == 0) {
                                    $("input[id$='AmountTotal']").val(TotalAmount);
                                    $("input[id$='GT']").val(TotalAmount);
                                }
                                else {
                                    for (var i = intidindex - 1; i >= 0; i--) {                                                     
                                       var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat( pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);
                                        $("input[id$='GT']").val(TotalAmount);
                                    }
                                }                                                      
                            }
                            if (TaxFormatval == "IGST") {
                                var Tax = $(this).parent().prevAll().eq(5).find("span[id*='LTax']").text()
                                var taxdividebytwo = parseFloat(Tax) / 100;
                                var IGSTval = AmountAfterDiscount * taxdividebytwo;
                                // alert(IGSTval);
                                $(this).parent().nextAll().eq(2).find("input[id*='TCGST']").val("0");
                                $(this).parent().nextAll().eq(3).find("input[id*='TSGST']").val("0");
                                //1. IGST set 10%  it ahs to show 284.85 
                                //$(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(3));
                                $(this).parent().nextAll().eq(4).find("input[id*='TIGST']").val(IGSTval.toPrecision(4));
                                var TotalAmount = AmountAfterDiscount + IGSTval;               
                                $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").val(TotalAmount);
                                //Item Total Amount
                                var id = $(this).parent().nextAll().eq(5).find("input[id*='TTotal']").attr('id');                         
                                var spitid = id.split('_');                         
                                var intidindex = parseInt(spitid[2])                           
                                    for (var i = intidindex - 1; i >= 0; i--) {
                                        var pretotal = $(this).parent().parent().prevAll().eq(i).find("input[id*='TTotal']").val();
                                        TotalAmount += parseFloat(pretotal);
                                        $("input[id$='AmountTotal']").val(TotalAmount);
                                        $("input[id$='GT']").val(TotalAmount);
                                }                         
                            }
                        }
                    })
                })
            })
        </script>

    Output:

    Best regards

    Cathy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 1, 2017 5:49 AM