TOPIC:

Re: Checkbox values need to be summed 10 years 10 months ago #10573

  • concoders's Avatar
  • concoders
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Working Smart is better then Working Hard
  • Posts: 12
  • Thanks: 0
Could you give me a more detailed "how to" on your solution - i have a similar problem and have no idea of how to set my form up like you did to salve your sum problem.

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

Re: Checkbox values need to be summed 10 years 10 months ago #10584

  • Topic Author
  • DavidLGCrawford
  • Visitor
  • Visitor
Step 1: Create a form using QuickMode

Step 2: Add your checkbox fields.

2a: Give them whatever LABEL you want, but make sure the NAME is something easy. For this example the names are d11, d12, d13, d14, d16, d18 and d1o (that last one is a lowercase letter o for "open", not the number zero).

2b: Give them a VALUE that is a dollar value. My values for this example are 35.00, 35.00, 35.00, 35.00, 45.00, 55.00, and 70.00.

2c: For each checkbox, click on the ADVANCED tab, and create an ACTIONSCRIPT event using CUSTOM, and check the action CLICK. In the code framework box put in this:
function ff_d11_action(element,action) {
ff_amountowing_action(element,action);
}
Make sure you change the title to match the NAME of this checkbox. So for box d12 it would look like this:
function ff_d12_action(element,action) {
ff_amountowing_action(element,action);
}
and so on.
Make sure you click SAVE PROPERTIES after each field is created!

Step 3: Create a text field with the NAME "amountowing" and a VALUE of 0.

3a: On the ADVANCED tab click on READ ONLY so that people can not alter the amount.
Under the ACTIONSCRIPT set it to CUSTOM. You do not need to click on any of the checkboxes, as this script runs from the checkboxes on your form (the ones you created in step 2).

3b: In the code framework add this:
function ff_amountowing_action(element,action)
{
   ff_getElementByName('amountowing').value = 0;
   if (ff_getElementByName('d11').checked)
   {
      ff_getElementByName('amountowing').value = Number(ff_getElementByName('amountowing').value) + Number(ff_getElementByName('d11').value);
   }
   if (ff_getElementByName('d12').checked)
   {
      ff_getElementByName('amountowing').value = Number(ff_getElementByName('amountowing').value) + Number(ff_getElementByName('d12').value);
   }
   if (ff_getElementByName('d13').checked)
   {
      ff_getElementByName('amountowing').value = Number(ff_getElementByName('amountowing').value) + Number(ff_getElementByName('d13').value);
   }
   if (ff_getElementByName('d14').checked)
   {
      ff_getElementByName('amountowing').value = Number(ff_getElementByName('amountowing').value) + Number(ff_getElementByName('d14').value);
   }
   if (ff_getElementByName('d16').checked)
   {
      ff_getElementByName('amountowing').value = Number(ff_getElementByName('amountowing').value) + Number(ff_getElementByName('d16').value);
   }
   if (ff_getElementByName('d18').checked)
   {
      ff_getElementByName('amountowing').value = Number(ff_getElementByName('amountowing').value) + Number(ff_getElementByName('d18').value);
   }
   if (ff_getElementByName('d1o').checked)
   {
      ff_getElementByName('amountowing').value = Number(ff_getElementByName('amountowing').value) + Number(ff_getElementByName('d1o').value);
   }
}
Note that to see all of that code you may have to scroll across! But you can just copy it and paste it into your form's code framework.

3c: Modify that code to replace the names with the ones you used in step 2. If you used my names (d11, d12, d13, d14, d16, d18 and d1o) then it will work as is.

Now save the properties, save the form, and publish.
As you click the checkboxes on and off the amount owing will be updated with the correct sums.

You can see it in action here: http://www.challengethechamp.ca/index.php/mushers/registration

Feel free to play with the form, even submit it if you choose (it's not being used live so play away).

Hope that helps!! :)

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

Re: Checkbox values need to be summed 10 years 10 months ago #10684

  • concoders's Avatar
  • concoders
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Working Smart is better then Working Hard
  • Posts: 12
  • Thanks: 0
is there a way to use this on an option box as well? I have a 10 page form will it carry the totals across all the pages? or just keep it on the same page?

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

Re: Checkbox values need to be summed 10 years 10 months ago #10685

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10064
  • Karma: 167
  • Thanks: 803
it will keep the values, sure

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

Re: Checkbox values need to be summed 10 years 10 months ago #10688

  • concoders's Avatar
  • concoders
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Working Smart is better then Working Hard
  • Posts: 12
  • Thanks: 0
what code do i use if i want to use check boxes instead of option boxes - so if chbox 1 is checked 2 and 3 are unchecked, if 2 is checked then 1 and 3 are unchecked (this will allow only one checkbox in my section to be checked)

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

Re: Checkbox values need to be summed 10 years 8 months ago #11744

  • cebby's Avatar
  • cebby
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 68
  • Karma: 1
  • Thanks: 0
I would also like to know this (or better still multiple radio group or select lists), although your code will enable me to get the results I need (not ideal, but at least it works :))

Now the important question, how do I pass the total amount owing to Paypal?

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

Last edit: Post by cebby.
Moderators: ForumSupport
Time to create page: 0.055 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

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!