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 onChange = the 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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kenlists% 40anderhome.com

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to