Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Can you count selected radio groups?
  FAQ FAQ  Forum Search   Register Register  Login Login

Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Can you count selected radio groups?

 Post Reply Post Reply
Author
Maki View Drop Down
New Member
New Member
Avatar

Joined: 13 Feb 2014
Location: Canberra, AUS
Points: 5
Post Options Post Options   Quote Maki Quote  Post ReplyReply Direct Link To This Post Topic: Can you count selected radio groups?
    Posted: 15 Feb 2014 at 11:45pm
Hi
Can I get Acro JS to return a numeric value for radio group if any of the buttons was pressed?

I'm trying to create a membership application form for a dog training club, which has fee calculation table at the end.
People applying for membership pay joining and membership fees per household and activity (course) fee per dog. The form has fields for max 6 dogs.
One activity, namely Canine Companion course, has 4 levels, which is made selectable with radio button group, and other courses are with checkboxes because these courses happen on different days and one dog can be enrolled in other activities simultaneously whereas it cannot be in different levels of Canine Companion course.

I'd like acrobat to return value 1 if any, and regardless of which, of the radio buttons of Canine Companion course is pressed.  This will be summed up at the fee calculation table as a number of dog in Canine Companion course and will be multiplied by 40 (all activity costs $40 per dog).

I've been reading John Deubert's ebooks but not well versed with JS programming. Hope someone can help.  Thank you.   Maki
Maki@Canberra, AUS
Back to Top
Maki View Drop Down
New Member
New Member
Avatar

Joined: 13 Feb 2014
Location: Canberra, AUS
Points: 5
Post Options Post Options   Quote Maki Quote  Post ReplyReply Direct Link To This Post Posted: 18 Feb 2014 at 7:16am
What I'm trying to achieve is best explained in this simplified version of my form.

http://bit.ly/1e2SAj3

There are fields to enroll MAX 6 dogs, hence 6 sets of radio button group, but most people enroll only one or two dogs. 

Canine Companion class has four levels but they all cost the same ($40).  I want to populate DogCount.0 field by counting Canine Companion level (K9CompLevel) radio button group that are selected.  Which level was selected within the group is not going to be an issue.

Advanced dog sports (Agility, Flyball, Trial Obedience) classes happen on the different days of the week to Canine Companion classes, therefore they are selectable with checkboxes.

Could someone please suggest custom calculation script to go into DogCount.0 field calculation?
Many many thanks.


Maki@Canberra, AUS
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 634
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 18 Feb 2014 at 9:52am
You can use this code as the field's custom calculation script:

var counter = 0;
for (var i=0; i<=6; i++) {
    if (this.getField("K9CompLevel_"+i).value!="Off")
        counter++;
}
event.value = counter;
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
Maki View Drop Down
New Member
New Member
Avatar

Joined: 13 Feb 2014
Location: Canberra, AUS
Points: 5
Post Options Post Options   Quote Maki Quote  Post ReplyReply Direct Link To This Post Posted: 19 Feb 2014 at 7:48am
It works great! Thank you so much!

However, can I ask one more question?

The calculation of Grand Total seems to happen always a few steps behind.
Is there a reason for this and a way to get around it?

The updated version of the form is here.
Maki@Canberra, AUS
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 634
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 19 Feb 2014 at 4:26pm
Yes, incorrect field calculation order.
You can set it to the right order in Form Edit mode, via Tasks - Other Tasks.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
Maki View Drop Down
New Member
New Member
Avatar

Joined: 13 Feb 2014
Location: Canberra, AUS
Points: 5
Post Options Post Options   Quote Maki Quote  Post ReplyReply Direct Link To This Post Posted: 19 Feb 2014 at 9:24pm
Another massive thanks, Gilad!
You made my day! Hug
Maki@Canberra, AUS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.031 seconds.