TOPIC:

Calculating on Form 5 months 1 week ago #239363

  • Topic Author
  • nigel
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 161
  • Thanks: 1
After following your tutorial I have a couple of questions

I have made a timesheet which people will enter Start time, Finish time and then there is a calculated field to work out the number of hours for that day.

I now wish to add all those calculated fields into a grand total of hours worked, how do I do that?

Also how can I select that the calculated number only shows two decimal points?

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

Calculating on Form 5 months 1 week ago #239376

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
Hello,

One option is to make the calculation of grand total in the Initialization script as follows.

Go to the Advanced properties of your form > More options > Scripts and in the Initialization section set Type to Custom. In the code area that appears put code like this:
function ff_FORMNAME_init()
{
setInterval('calc()', 500);
} // ff_FORMNAME_init

function calc() {
var grandsum = 
    Number(ff_getElementByName('firstField').value) + 
    Number(ff_getElementByName('secondField').value) + 
    Number(ff_getElementByName('thirdField').value);

    ff_getElementByName("Grand_total").value = Number(grandsum).toFixed(2);
}
NOTE: In the code above, replace FORMNAME with the name of your form.
Also, replace "firstField", "secondField" and "thirdField" with the Names of the fields that should be included in the calculation.

Another option is to add this line of code to the Actionscript of EACH element whose value is included in the calculation:
    ff_Grand_total_action();

In the "Grand_total" field you would have to put code like this:
function ff_Grand_total_action(element, action)
{
var grandsum = 
    Number(ff_getElementByName('firstField').value) + 
    Number(ff_getElementByName('secondField').value) + 
    Number(ff_getElementByName('thirdField').value);

    ff_getElementByName("Grand_total").value = Number(grandsum).toFixed(2);
} // ff_Grand_total_action

NOTE: In this code, it is assumed that the name of the total field is "Grand_total".

The code provided also rounds the total number to two decimal places.

Let me know whether you have managed to apply this to your form.

Regards,

Mihaela

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

Calculating on Form 4 months 3 days ago #239770

  • tinwistle
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 7
  • Thanks: 0
I'm trying to do this and am having trouble getting it to work, yet I did it years ago so I know it is possible. I need to add two drop down lists together to come up with a total.

I tried both examples but not sure if I am putting the code into the right places?

See how it use to work...
web.archive.org/web/20161102170825/http:...dex.php/registration

And now what I am try to get to do the same functionality.

stupidbrothers.ca/index.php/register-now

Thanks you

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

Calculating on Form 4 months 3 days ago #239774

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
Hello,

When I select Golfers or Banquet in this form stupidbrothers.ca/index.php/register-now the following errors are displayed in the console:
Uncaught ReferenceError: ff_golfers_action is not defined...
Uncaught ReferenceError: ff_Banquet_action is not defined...
which means that you haven't defined the Actionscript properly.

Can you provide me the code you are using at the moment?
Using the instructions from this piece of documentation crosstec.org/en/support/online-documenta...ting-textfields.html you should be able to make it work.

Note that in order for this to work you have to properly define options of the select lists which are included in the calculation.

Regards,

Mihaela

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

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

July Sale!

Discounts for all of our extensions + support. Ending July 31st!

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!