Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
529 Points
265 Posts
Feb 27, 2012 11:06 AM|LINK
I will prefer to use a class name for the controls(textboxes)... In furtur days if adding new cols also there won't be any problem ....
Example:
<table> <tr> <td> <input type='text' class='col1' /> </td> </tr> <tr> <td> <input type='text' class='col1' /> </td> </tr> </table>
In the above table u have two rows with one cols, each row has a textbox .. with same class name ..
Now the Jquery Code Will Be like ...
var sumofCol1 = 0;
$('.col1').live('keyup', function() {
$('input.col1').each(function(){ sumofCol1 = sumofCol1 + $(this).val(); });
});
Finally Assign sumofCol1 to a label in the footer ....
I used live for evnt binding because, you are creating row at time ... so 'live' ll be help full...
** Take Care of Converting value to int or float e.t.c ...
vijay.reddy5...
Member
529 Points
265 Posts
Re: calculate row total and column total using java script or quivery
Feb 27, 2012 11:06 AM|LINK
I will prefer to use a class name for the controls(textboxes)... In furtur days if adding new cols also there won't be any problem ....
Example:
In the above table u have two rows with one cols, each row has a textbox .. with same class name ..
Now the Jquery Code Will Be like ...
$('.col1').live('keyup', function() {$('input.col1').each(function(){ sumofCol1 = sumofCol1 + $(this).val(); });Finally Assign sumofCol1 to a label in the footer ....
I used live for evnt binding because, you are creating row at time ... so 'live' ll be help full...
** Take Care of Converting value to int or float e.t.c ...
Check my website for ASP.Net Articles -
My Website