$(function(){
    $("input[id*='tbQuantity']").each(function() {
        $(this).keyup(function(){
           if (isNaN($(this).val()))
           {
               alert('ÇëÊäÈëÊý×Ö');
               $(this).val(1);
           }
           sum(this);
           var total = 0.0;
           $("span[id*='lblTotal']").each(function() {
               if (!isNaN($(this).text()))
               {
                   total += parseFloat($(this).text());
               }
           });
           $("span[id*='lblSum']").text(total.toFixed(2));
        });
    });
    
    function sum(obj) {
        reg = /tbQuantity/g;
	    var idtag = obj.id.replace(reg,"");

	    pr = document.getElementById(idtag + "lblPrice").innerText;
	    qt = document.getElementById(idtag + "tbQuantity").value;
	    am = qt*pr;
	    document.getElementById(idtag + "lblTotal").innerText = am.toFixed(2);
    };
})
