hello there! thank you so much, this code worked great!!!! However,
i'm trying to apply this same code to a second object that is
performing an additional calcuation and i'm have A LOT of trouble and
would LOVE your help or anyone else's help.
I can’t figure out a way to modify the calculation on the parent row
when an additional row is selected. Essentially, I need it to perform
the same calculation that the last row performs, but ONLY when an
additional row is selected, otherwise, I need it to perform the
calculations that it currently performing.
The problem I’m having is that if there is only one row, then I need a
completely different set of calculations to occur.
My calculations are dependent on:
1. If a checkbox is checked
2. The number of days that is entered
3. The number of rows that are added
The middle rows are working fine, and so are the first (parent) and
last rows when the domestic checkbox is not checked.
Here is my code for the object that performs the calculation:
topmostSubform.Page1.MIEexpSection.MIEexp.gsaTotal::calculate -
(JavaScript, client)
//variable//
var sResult = ""
//first row only and domestic and total days less than or equal to
two//
if (this.parent.index == 0 & domestic.rawValue & Days.rawValue <= 2 )
{
sResult = partial.rawValue * Days.rawValue;}
//first row only and domestic and total days is greater than two//
else if (domestic.rawValue & Days.rawValue > 2 &(this.parent.index ==
0)) {
sResult = perDiem.rawValue * (Days.rawValue - 2) + (partial.rawValue *
2);}
//more than one row, first row and last row calculations//
else if (this.parent.index ==(this.parent.instanceManager.count - 1) &
domestic.rawValue & Days.rawValue == 1)
sResult = partial.rawValue
else if (this.parent.index ==(this.parent.instanceManager.count - 1) &
domestic.rawValue & Days.rawValue == 2)
sResult = partial.rawValue + perDiem.rawValue
else if (this.parent.index ==(this.parent.instanceManager.count - 1) &
domestic.rawValue & Days.rawValue > 2)
sResult = perDiem.rawValue * (Days.rawValue - 1) + partial.rawValue
else
//if domestic is not checked//
{
sResult = perDiem.rawValue * Days.rawValue;}sResult;
On Dec 21 2011, 1:05 pm, "fred.pantalone" <
fred.pantal...@gmail.com>
wrote:
> Ok, then use something like this JavaScript on the calculate event of
> the field that will display the result of the calculation:
>
> var sResult = "";if ( this.parent.index == 0 || this.parent.index ==
> (this.parent.instanceManager.count - 1) ) { // this is the first or
> last instance of repeatableSubform sResult = "first or last
> row";} else{ sResult = "middle row";}sResult;
>
> On Dec 21, 11:28 am, Diana <
diana.va...@utsa.edu> wrote:
>
>
>
> > The calculation will be performed within the repeating subform.
>
> > On Dec 21, 9:26 am, "fred.pantalone" <
fred.pantal...@gmail.com> wrote:
>
> > > Where is the calculation going to be performed? Is it outside of the
> > > set of repeating subforms or in a field within a repeating subform?
>
> > > Fred
>
> > > On Dec 20, 5:34 pm, Diana <
diana.va...@utsa.edu> wrote:
>
> > > > Thanks Fred - however, i'm still confused. Should I add this to the
> > > > calculate event in the object where the calculation will occur?
>
> > > > On Dec 20, 3:50 pm, "fred.pantalone" <
fred.pantal...@gmail.com> wrote:
>
> > > > > Here is the logic in pseudo-ish JavaScript:
>
> > > > > if (repeatableSubform.index == 0 || repeatableSubform.index ==
> > > > > (repeatableSubform.instanceManager.count - 1) )
> > > > > {
> > > > > // this is the first or last instance of repeatableSubform
>
> > > > > }
>
> > > > > On Dec 20, 4:35 pm, Diana <
diana.va...@utsa.edu> wrote:
>
> > > > > > How can I identify the first and last row in arepeatablesubform? I’m
> > > > > > using instanceManager and managed to calculate the total number of
> > > > > > rows using FormCalc, however, I don’t know how to identify the first
> > > > > > and last row.
>
> > > > > > This is what I need to do:
>
> > > > > > Therepeatablesubform contains a checkbox. If this checkbox is
> > > > > > checked in the first and/or last row (of therepeatablesubform), then