Geting avg of fields

C

coffee-girl

Hi there.

what i'm trying to do is have a few fields that the user can enter numbers..

so i have field1, field2, field3, field4..
and field5 witch will do this (field1 + field2 + field3 + field4) / 4

what i would like to do is have / 4 change as per number of fields enter so
if they only entered in field1, field2 and field 3 the formula would be
(field1 + field2 + field3) / 3

i donut even know where to start.. i have the first one working but having
trouble doing the second part.. can one one please help me have been at this
for a long time...
 
P

psiEnergos

Coffee-girl,

Regardless if you are developing the form with script or managed code (with
the VS SDK) you will need to declare variables to track the number of nodes
you are processing.

ex
{VS}
DIM NumberOfNodes
NumberOfNodes={Number of fields; this could be calculated with the same loop
that adds Field1+Field2....}

NumberOfNodes = NumberOfNodes + 1

{JS}
VAR NumberOfNodes
NumberOfNodes={Number of fields; this could be calculated with the same loop
that adds Field1+Field2....}
NumberOfNodes++

{C#}
int NumberOfNodes
NumberOfNodes={Number of fields; this could be calculated with the same loop
that adds Field1+Field2....}

NumberOfNodes++


Then the average is quite simple: SumOfAllFields / NumberOfNodes

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top