Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use jquery for calculation in grid all done well instead that when it is grand total turn jquery throw an error "Uncaught TypeError: undefined is not a function" at this line " $("[id*=txtTotal]").live("keyup", function () {", kindly give me suggestion.

JavaScript
function CalculateTotal(select) {

                var row = $(select).closest("tr");
                var ClPart = $("[id*=txtCl_Part]", row).val();
                //alert(ClPart.toString());
                var Assgnmnt = $("[id*=txtAssgnmnt]", row).val();
                //alert(Assgnmnt.toString());
                var Quiz = $("[id*=txtQuiz]", row).val();
                //alert(Quiz.toString());
                var WrPaper = $("[id*=txtWP]", row).val();
                //alert(WrPaper.toString());
                var OSME = $("[id*=txtOSME]", row).val();
                //alert(OSME.toString());
                var Total = (parseFloat(ClPart.valueOf()) + parseFloat(Assgnmnt.valueOf()) + parseFloat(Quiz.valueOf()) + parseFloat(WrPaper.valueOf()) + parseFloat(OSME.valueOf()));
                //   alert(Amount.toString());

                $("[id*=txtTotal]", row).val(Total.valueOf());
            }

            $("[id*=txtTotal]").live("keyup", function () {
		                    
			"Error comes at above line"

		var Gtot = 0;
                    var percent = 0.0;
                    $("[id*=txtTotal]").each(function (index) {
                        //Check if number is not empty
                        if ($.trim($(this).val()) != "")
                        //Check if number is a valid Float
                            if (!isNaN($(this).val()))
                                Gtot = Gtot + parseFloat($(this).val());
                        percent = (parseFloat(Gtot) * 100) / 400;
                    });

                    $("[id*=txtGTot]").val(Gtot.valueOf());
                    $("[id*=txtPercent]").val(percent.valueOf());

                });
Posted
Comments
Sergey Alexandrovich Kryukov 22-Jul-14 20:52pm    
.live() is deprecated, use .on(), or, for older jQuery, .delegate(). Checkup the result of the selector, could be undefined.
—SA
Muhammad Bilal Khan 23-Jul-14 14:47pm    
thanks Sergey. It had done exactly like this
Sergey Alexandrovich Kryukov 23-Jul-14 16:48pm    
Sure.
—SA

it finally works...

Joel it will something like this

$(documnet).on("event","selector", function() {} )
 
Share this answer
 
Please pay attention: .live() is deprecated, use .on(), or, for older jQuery, .delegate(). Checkup the result of the selector, could be undefined. I already put it in my comment to the question. Please see:
http://api.jquery.com/live[^].

—SA
 
Share this answer
 

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