Form Help

TOPIC:

Need to count number of items checked in Checkbox Group 3 weeks 1 day ago #245413

  • Topic Author
  • guitrldy
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 31
  • Thanks: 0
Hello! I need to count the number of items checked in Checkbox Group.

Would I be able to do this similarly to counting single checkbox items like in this example?:
crosstec.org/en/support/online-documenta...g-checkbox-sums.html


I've tried this:

. Gave my checkbox items each a value of 1 (lizardList12).

0;Bearded Dragon;1
0;European Legless Lizard;1
0;Uromastyx (Egyptian);1
0;Uromastyx (Mail);1


. Created a textfield (animalTotal) item with this code added to ActionScript:
function ff_animalTotal_action(element,action)
{
     ff_getElementByName('animalTotal').value = 0;
      
     if (ff_getElementByName('lizardList12').checked)
     {
          ff_getElementByName('animalTotal').value = 
          Number(ff_getElementByName('animalTotal').value) + Number(ff_getElementByName('lizardList12').value);
     } 
}


My code above is resulting in "0" (zero) only. Help!
Thanks!
Lisa W.

Please Log in or Create an account to join the conversation.

Need to count number of items checked in Checkbox Group 3 weeks 1 day ago #245414

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 9796
  • Karma: 167
  • Thanks: 785
Hi,

the example calculates the sum of values of checkboxes, not the amount of checked checkboxes.

Please try this instead
function ff_animalTotal_action(element,action)
{
   let checkboxes = JQuery("[name=\""+JQuery(element).attr("name")+"\"]:checked");
   ff_getElementByName('animalTotal').value = checkboxes.length;
}

Please Log in or Create an account to join the conversation.

Need to count number of items checked in Checkbox Group 3 weeks 1 day ago #245415

  • Topic Author
  • guitrldy
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 31
  • Thanks: 0
Perfect!
Thanks!

Lisa W.
PS. Thanks for the quick reply!

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.033 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

Summer Sale!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!