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

Need help on how to calculate average out of checkbox values

Cheska
Registered: Jan 23 2009
Posts: 22
Answered

Hello everyone!

This is my first time to create a form using livecyle. I never knew form created in designer was different from acrobat. Thanks to George_Johnson for pointing that out.

I happened to create my form in livecycle so here I am hoping someone can help me with my problem with the calculation of average using checkbox values. Simple calculation would just be:

average = the sum of checkbox values / the count of the rows.

I have 4 checkboxes (set to global and having the same field name) in a row and 7 rows. However, not all 7 rows may be answered therefore throwing off my calculation because my denominator remains 7.

I was given a javascript (for loop) but it did not work. Is there a way to calculate the average making the denominator a variable wherein a condition is set to count only the checkboxes that are checked or which values are not zero? If so, please help me with the codes.

Thank you in advance.

Cheska

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If the check boxes all have the same name, and are set to global, then don't they all turn off and on at the same time? Do you mean that you are using a Radio Button group?

Anyway, all you have to do is put a counter in the "sum" loop. If a value is 0, then don't increment the counter. To get the average, divide the sum by the counter. I think that George already pointed this out in your previous thread.

To provide more info you'll have to explain a bit more about your form. For example, what are the names of the fields and how are they organized in subforms?

You can learn more about using LiveCycle to create forms, and scripting in particular from this video:
https://admin.adobe.acrobat.com/_a200985228/p87746471/

You'll find more video tutorial on this at www.pdfscripting.com.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Cheska
Registered: Jan 23 2009
Posts: 22
Thank you for your reply. This issue was with the form I created in Livecycle. I used 4 checkboxes (cb) in a row with "On values" ranging from 1-4. I entered the same name for the 4 cb, the system provided me with an extension name ranging from 0-3 ( ex. cbSec1A1.0, cbSec1A1.1, etc...). When I set the binding properties to global, this was what made it behave where only 1 cb can be checked in a row. The issue was in calculation of the average where I am excluding rows that have no "On" values or which values > 0. All kinds of javascripts suggested by several people did not work for me in that form so I set that aside.As George suggested, I created another one from scratch. Started the skeleton table or template in MSWord. Saved as pdf and started working in Acrobat. The same javascript worked perfectly in acrobat except that I have another error each time the calculation = zero. It is telling me about an incorrect format.

Also, what I have discovered is that Acrobat 7.0 cannot recognize MSWord 2007 docs. I had to save the doc to a 2003 format or save the doc as pdf before I can open it in Acrobat 7.0.

Thanks for the help.

Cheska
Cheska
Registered: Jan 23 2009
Posts: 22
Now that you mentioned Radio button, I think that was what was wrong with my form in the livecyle. I think I need to use radio button instead of checkboxes.

I'll try that and let you know.

Thanks.

Cheska
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So are you talking about a LiveCycle form or an AcroForm? Without this information it's impossible to answer the question. You do know that this is the LiveCycle forum.

Next time you answer, or post a new question, please clearly state the technology you are using the the issue at hand. It's best to stick with a single issue in a single post.

You're posts above are very confusing. Please be clear and stick to a single issue.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Cheska
Registered: Jan 23 2009
Posts: 22
I apologize. Thank you for pointing that out. It is a form created in livecycle. When I got frustrated with it I sat that aside and I re-created in acrobat (which I was able to make the javascript calculation work). But not so happy with it so I am going back to livecycle.

Anyway, I think I know what I did wrong after you mentioned the "global settings". I'll keep you informed if I ever make it work.

Thanks a lot and thanks for the links, Thomp.

Cheska