 Level 1

0% to Level 2

Tip /

to gain points, level up, and earn exciting badges like the new
Mission!

View all  Level 1

i have used adobe livecycle designer Es2 for making form, i want to calculate the standard deviation for 5 feilds named (F1,F2,F3,F4,F5) which is numeric and i think that this can be done through a custom calculating script.. can you help me please in a code to perform this calculation... the previous was in adobe acrobat pro but when use the same code it does not work with adobe livecycle designer.. please help me in this issue

thsi was the code that i use in adobe acrobat pro:

var MyValues = new Array();

var MyFields = new Array("F1", "F2", "F3", "F4", "F5");

var oField;

var nField;

for(var i = 0; i < MyFields.length; i++)

{

nField = '';

nField = GetField(this, MyFields[i]).valueAsString;

if(nField != "") MyValues.push(Number(nField));

}

event.value = standardDeviation(MyValues);

so i need code perform the same function for adobe livecycle designer

thank you

4 Replies  Level 7

The code for the function "standardDeviation" is placed in a document level JavaScript object. This is a user written function.

The documentation under Help in LiveCycle has documentation on how to do this and convert the JavaScript for the field to FormCalc or JavaScript.  Level 1

Hello, i try to find it but i cant

thanks  Level 10

Hi,

Try this;

function average(data) {

var sum = data.reduce(function (sum, value) { return sum + value; }, 0);

var avg = sum / data.length;

return avg;

}

function standardDeviation(values) {

var avg = average(values);

var squareDiffs = values.map(function (value) { var diff = value - avg; var sqrDiff = diff * diff; return sqrDiff; });

var avgSquareDiff = average(squareDiffs);

var stdDev = Math.sqrt(avgSquareDiff);

return stdDev;

}

var MyValues = new Array();

var MyFields = new Array("F1", "F2", "F3", "F4", "F5");

var oField;

var nField;

for(var i = 0; i <
MyFields.length; i++)

{

nField = '';

nField = xfa.resolveNode(MyFields[i]).rawValue;

if(nField != "") MyValues.push(Number(nField));

}

standardDeviation(MyValues);

Regards

Bruce  Level 7

I would put the functions at the document level so they would be available to any form field in the PDF. If one is computing the standard deviation the average moght also be in another field.  