Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running Totals



Daniel,

I've done something like this.  Basically, I create fields in the repetition where the name of the field (as in the 'name' field in the static inspector) is a well-known value with an index, like 'calcField0', 'calcField1', etc.  Then, I load up some _javascript_ that will recalculate these fields, and make sure that any field that's part of the calculation has _javascript_ function that recalcs.  I set the field names by having a method in my WOComponent subclass like this:

public String distFieldName() {
return "dist"+distIndex;
}

The distIndex is an indexer on the repetition (the 'index' attribute of the repetition):

distributions: WORepetition {
item = distribution;
list = editingPayment.distributions;
index = distIndex;
}

Then, your _javascript_ can do something like:

function recalcDists() {
var total = 0.00;
var max = document.addressbookForm.elements.length;
var index = 0;
while (index < max) {
if (document.addressbookForm.elements[index].name.length > 4) {
if (document.addressbookForm.elements[index].name.substring(0,4) == "dist") {
total = total + eval(document.addressbookForm.elements[index].value);
}
}
index++;
}
document.addressbookForm.totalDist.value = custRound(total,2);
}

Good luck!

Ken


On Jul 30, 2007, at 12:59 PM, Daniel Brajkovic wrote:

Does anyone know of a way I can have a running total in WO repetition?  Maybe in _javascript_? Because I'd want it to be pretty dynamic.  Change a column 2 value and all the column 3 values would change appropriately. For the life of me i just can't figure out a way. 


For Example

Data1 $12.00 
Data2 $14.00
Data3 $20.00

A new 3rd column would read:

Data1 $12.00 $12.00
Data2 $14.00 $26.00
Data3 $20.00 $46.00
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/email@hidden

This email sent to email@hidden

References: 
 >Running Totals (From: Daniel Brajkovic <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.