0

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.


Here is my code:

            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());

            });
8
  • 1
    You may forgot to included JS librery. Kindly check! Commented Jul 22, 2014 at 20:51
  • I include jquery library like this <script src="../Scripts/jquery-1.11.1.min.js" type="text/javascript"></script> but i only inclde the above file. Is it enough or not? Commented Jul 22, 2014 at 20:55
  • 1
    And when you view your browser's debugging tools, does it show that it successfully loaded the jQuery library script? Commented Jul 22, 2014 at 20:56
  • Also, cross check the order of JS library included in your code and path. Thanks Commented Jul 22, 2014 at 20:57
  • yes mason, the code above that line is working fine but it stuck at that line Commented Jul 22, 2014 at 20:57

3 Answers 3

2

Live was removed in jquery 1.9 per documentation (https://api.jquery.com/live/).

Instead, use the new "on" method

$("[id*=txtTotal]").on("keyup", function () {});
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks joel. it help me. the error i get is solved but this code is not running. can you help me on this?
it finally works... Joel it will something like this $(documnet).on("event","selector", function() {} )
0

//Let you handle an element even if it's not registered in DOM

$(document).on("keyup", "#<%=txtTotal.ClientID%>", function() {});

//Or do this

$("#<%=txtTotal.ClientID%>").keyup(function() {});

//Or this

$("#<%=txtTotal.ClientID%>").on("keyup",function() {});

Comments

0

it finally works...

Joel it will something like this

$(documnet).on("event","selector", function() {} )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.