Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion sum of table rows

Received: by 10.35.124.20 with SMTP id b20mr18489626pyn.5.1201119535603;
        Wed, 23 Jan 2008 12:18:55 -0800 (PST)
Return-Path: <dswit...@pengoworks.com>
Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.123])
        by mx.google.com with ESMTP id z53si730954pyg.1.2008.01.23.12.18.55;
        Wed, 23 Jan 2008 12:18:55 -0800 (PST)
Received-SPF: neutral (google.com: 71.74.56.123 is neither permitted nor denied by best guess record for domain of dswit...@pengoworks.com) client-ip=71.74.56.123;
Authentication-Results: mx.google.com; spf=neutral (google.com: 71.74.56.123 is neither permitted nor denied by best guess record for domain of dswit...@pengoworks.com) smtp.mail=dswit...@pengoworks.com
Received: from dreamtheater ([65.24.39.33]) by hrndva-omta06.mail.rr.com
          with ESMTP
          id <20080123201854.TLST2392.hrndva-omta06.mail.rr.com@dreamtheater>
          for <jquery-en@googlegroups.com>; Wed, 23 Jan 2008 20:18:54 +0000
From: "Dan G. Switzer, II" <dswit...@pengoworks.com>
To: <jquery-en@googlegroups.com>
References: <c13f943e-4943-43ba-9731-e85c1813ef6b@h11g2000prf.googlegroups.com> <5ca90109-f034-437f-8fec-34a14b8d7b7f@k2g2000hse.googlegroups.com> <103001c85de7$68b72240$0a01a8c0@dreamtheater> <15050352.post@talk.nabble.com>
Subject: RE: [jQuery] Re: sum of table rows
Date: Wed, 23 Jan 2008 15:18:31 -0500
Organization: PengoWorks LLC
Message-ID: <108101c85dfd$21321ae0$0a01a8c0@dreamtheater>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 11
Thread-Index: Achd+NqMLbQyFQFgRPKe6BUKyqf8RAAA3WCQ
In-Reply-To: <15050352.post@talk.nabble.com>
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198

Rolf,

>That's a nice little plugin Dan! Is it possible to sum a column of text
>inputs as they're filled (self-totalling, rather than onClick)?

Sure! You'd just need to trigger sum() event to occur on a keypress event.
If you're going to do that, I'd definitely recommend caching the jQuery
object you're going to perform the sum() on (that way you're not spending
cycles always looking up which elements to sum().)

One neat feature is that you can mix and match element types with the
mathematical functions. So you can sum a text element against a div element.

I just realized the description text on the page is completely wrong! It's
for another plug-in and I used that page as a template for this one. :)

-Dan

>
>
>Dan G. Switzer, II wrote:
>>
>>
>> It sounds as if this might be a good candidate for my Calculation plug-
>in:
>> http://www.pengoworks.com/workshop/jquery/calculation.plugin.htm
>>
>> $("tr").each(function (){
>> 	var sum = $("span.length", this).sum();
>> 	var person = $("td.person").text();
>>
>> 	alert(person + " = " + sum);
>> });
>>
>> -Dan
>>
>>
>
>--
>View this message in context: http://www.nabble.com/sum-of-table-rows-
>tp14879031s27240p15050352.html
>Sent from the jQuery General Discussion mailing list archive at Nabble.com.