These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Javascript help finding averages

ben.smith
Registered: Dec 16 2008
Posts: 11

I need some Javascript help with finding the correct averages in my document.

I have created a survey with 8 different sections and each section once filled out gets a percentage score. Then at the end of the survey there is a field that calculates an overall average of all the percentages.

I failed to realize that 2 of the sections may or may not be filled out depending on the participant so if they don't fill out a section they get a 0% score for that section thus throwing off the total score.

Is there a simple script for calculating the overall score from the 8 sections and determining the correct average if any of the sections aren't filled out?

Any help with this would be very helpful as I am a new user and have hit a complete roadblock here. I am using acrobat 8 pro 8.1.3. Thanks.

My Product Information:
Acrobat Pro 8.1.3, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You need to keep a counter of the number of sections filled and a variable for the total.
Scan all the sections and check if they are zero. If not, add one to the counter and the value of the section to the total variable.
Once you're done you simply divide the total in the sections counter and you got your average.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com