Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The Below is the table where i display a list of fees with the amount,
the fees list is display on the basis of class later i will that fees list to
a selected student in the class.

HTML
<form method="post" action="#" class="form_class" novalidate="novalidate" enctype="multipart/form-data">

            <table id="TableStudent" cellspacing="0" cellpadding="0" border="1" class="sTable3">
                width="100%">
                <tbody class="TableData">
                @{
                    var count=0;
                    string Transferprefix = "CUSTOM_STUDENT_FEEALLOCATION_DETAIL[{0}].";
                    string strTransferprefix = "";
                    //string STUDENT_NAME = ViewBag.Name;
                    //string Admission_No = ViewBag.Admission;
                    foreach (var student1 in ViewBag.StudList)
                   {
                       strTransferprefix = String.Format(Transferprefix,count);
                        <tr rownumber="@count">
                         <td align="center" width="2%">
                        <input type="checkbox" name="@(strTransferprefix + "SELECTED_STUDENT")" id="@("SELECTED_STUDENT-" + count)" class="SelectStudent" value="True" checked="checked" />  
                         <input type="hidden" name="@(strTransferprefix + "Registration_Id")" id="@("Registration_Id-" + count)" value="@student1.Registration_Id" />
                                <input type="hidden" name="@(strTransferprefix + "Admission_No")" id="@("Admission_No-" + count)" value="@student1.Admission_No" />
                         </td>
                         </tr>
foreach (var student in ViewBag.FeesDetails)
                   {
                       //var count1 = 0;
                       //string Transferprefix1 = "CUSTOM_STUDENT_FEEALLOCATION_DETAIL[{0}].";
                       //string strTransferprefix1 = "";
                       strTransferprefix = String.Format(Transferprefix, count);
                        <tr rownumber="@count">
                         <td align="center" width="2%">
                          @*<input type="checkbox" name="@(strTransferprefix + "SELECTED_STUDENT")" id="@("SELECTED_STUDENT-" + count)" class="SelectStudent" value="True" checked="checked" />
                                 <input type="hidden" name="@(strTransferprefix + "Registration_Id")" id="@("Registration_Id-" + count)" value="@student.Registration_Id" />
                                <input type="hidden" name="@(strTransferprefix + "Admission_No")" id="@("Admission_No-" + count)" value="@student.Admission_No" />*@
                                <input type="hidden" name="@(strTransferprefix + "Fee_Master_Id")" id="@("Fee_Master_Id-" + count)" value="@student.Fee_Master_Id" />
                                <input type="hidden" name="@(strTransferprefix + "Class_Id")" id="@("Class_Id-" + count)" value="@student.Class_Id" />
                                <input type="hidden" name="@(strTransferprefix + "Academic_Year_Id")" id="@("Academic_Year_Id-" + count)" value="@student.Academic_Year_Id" />
                                <input type="hidden" name="@(strTransferprefix + "Academic_Year_Name")" id="@("Academic_Year_Name-" + count)" value="@student.Academic_Year_Name" />
                                <input type="hidden" name="@(strTransferprefix + "Fee_Type_Name")" id="@("Fee_Type_Name-" + count)" value="@student.Fee_Type_Name"/>
                                <input type="hidden" name="@(strTransferprefix + "Period_Name")" id="@("Period_Name-" + count)" value="@student.Period_Name" />
                                <input type="hidden" name="@(strTransferprefix + "Fee_Category_Name")" id="@("Fee_Category_Name-" + count)" value="@student.Fee_Category_Name"/>
                                <input type="hidden" name="@(strTransferprefix + "Amount")" id="@("Amount-" + count)" value="@student.Amount" />
                                @*<input type="hidden" name="@(strTransferprefix + "grosstotal")" id="@("grosstotal-" + count)" value="@student.grosstotal" class= "Amount" />*@
<td align="left" width="20%">
                                @student.Academic_Year_Name
                            </td>
                            <td align="left" width="20%">
                                @student.Fee_Type_Name
                            </td>
                            <td align="left" width="20%">
                                @student.Period_Name
                            </td>
                            <td align="left" width="20%">
                                @student.Fee_Category_Name
                            </td>
                            <td align="center" width="20%">
                                @student.Amount
                            </td> </td></tr>
                    }
                   }
                   }
</tbody>
                
                </table>
                             <span style="float:right">TOTAL FEES &nbsp &nbsp
                <input type="text" id="grosstotal" name="grosstotal" value="" class="Amount"/></span> 
                <div class="form_default" style="clear: both;">
                <button id="submit" type="submit" value="submit" class="showbutton">
                    SUBMIT
                </button>
                <button id="btnCancel" type="button" class="showbutton">
                    Cancel</button>
                   
                  </div>
                </form>


i Want to calulate the sum of amount, and dispaly the total in the gross total textbox.
Posted
Updated 25-Jun-15 0:25am
v2

1 solution

Let this be the sample table




a 2 c d
a 3 c d


To perform sum on the second column i.e., 2+3=5 then following jquery will accomplish the task

var total=0;
$("#table td:nth-child(2)").each(function (index) {
// $(this).html() will fetch the each cell value of column 2

total=parseInt($(this).html())+total;
alert(total);
});
 
Share this answer
 
Comments
Mohammed Rizwanullah 27-Jun-15 2:15am    
Thanks Bhanu Prasad my prob solved...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900