Expand my Community achievements bar.

Mathematical Functions in a Table

Avatar

Level 2

I have a 6x1 table and in one of the cells I want to create a formula that multiplies two items together to form a total that automatically calculates as you enter in numbers. In this case it is multiplying the "Goal 1 Weight" by "Percentage Achieved" to acquire "Weighted Score"

Later on in the form I will want to pull in the 6 weighted scores and sum them up as well.  I know this is poissible in either Java or FormCalc, thanks for any help!

4 Replies

Avatar

Level 6

Hello,

Please check the attached updated pdf.

java script placed under variable of the form.

some more script place on each row fields exit of "Goal 1 Weight" and "Percentage Achieved".

Hope this will help.

Thanks,

Raghu.

Avatar

Level 2

Raghu,

Unfortunately something went wrong when you uploaded the file and it can not be opened, could you try it again or paste the Java script in the message and tell me where to insert it.

Avatar

Level 6

I am able to download and its working properly.

If not please follow the below steps to get the same. I attached same file u can try, if still same problem send me ur email i will mail the same form.

For first and last rows fields GW1, GWPercent exit events add this script.(because you stated fields are text type insted of numeric)

if(form1.variables.js.validateInteger(GWPercent.rawValue) && form1.variables.js.validateInteger(GW1.rawValue))
{
GWWeight.rawValue = (Number(GWPercent.rawValue) * Number(GW1.rawValue));
}


For rest of the rows fields GW2, GWPercent exit events add this script.

GWWeight.rawValue = (GWPercent.rawValue * GW2.rawValue);


To get total of all rows Weighted Score can call the below function on form ready event

function calcTotal(){

form1.SubformAllDocument.SubFormValues.NumericField1.rawValue =
     Number(form1.SubformAllDocument.SubformRatings.Table1Scores.Row1.GWWeight.rawValue) +
    form1.SubformAllDocument.SubformRatings.Table2Scores.Row1.GWWeight.rawValue +
    form1.SubformAllDocument.SubformRatings.Table3Scores.Row1.GWWeight.rawValue +
    form1.SubformAllDocument.SubformRatings.Table4Scores.Row1.GWWeight.rawValue +
    form1.SubformAllDocument.SubformRatings.Table5Scores.Row1.GWWeight.rawValue +
    Number(form1.SubformAllDocument.SubformRatings.Table6Scores.Row1.GWWeight.rawValue);
}


helper methds

function isEmpty(str) {
if(str == null || str.length == 0) {
  return true;
}
return false;
}

function validateInteger( strValue ) {
var objRegExp  = /^\d+$/;
return objRegExp.test(strValue);
}

Thanks.

Avatar

Level 2

Is it easier to change the table parts to a numeric field?  Simplifying would be a good thing.