TOPIC:

Calculate Textarea 2 weeks 2 days ago #249191

  • Topic Author
  • mrperfectpz
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 337
  • Thanks: 0
How would I sum all the numbers in a textarea and put the total in a textbox ?

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

Calculate Textarea 2 weeks 1 day ago #249204

  • tihana.krivic's Avatar
  • tihana.krivic
  • Away
  • Moderator
  • Moderator
  • Posts: 1661
  • Karma: 3
  • Thanks: 149
Hi,

I create an example for you.

File Attachment:

File Name: textarea_calc.zip
File Size:6 KB

Please download->unzip and install it.
Code is located in form->Advanced->More options->Scripts->Init.script

Let me know if it works for you

Regards,
Tihana
Attachments:

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

Calculate Textarea 2 weeks 1 day ago #249222

  • Topic Author
  • mrperfectpz
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 337
  • Thanks: 0
I tried this, doesnt seem to work. Even your example doesnt work when I type in new numbers, it should add as entered.

Regards

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

Calculate Textarea 2 weeks 1 day ago #249223

  • tihana.krivic's Avatar
  • tihana.krivic
  • Away
  • Moderator
  • Moderator
  • Posts: 1661
  • Karma: 3
  • Thanks: 149
Hi,

my form works well I am using Init.script -> when form is loaded shows total
As I understood you correctly then you can do this:
go to your total element->Advanced->check Custom->check Blur and put this:
function ff_nameoftotalelement_action(element, action)
{
    switch (action) {
        case 'blur':
ff_getElementByName('nameoftotalelement').value=ff_getElementByName('nameoftextarea').value.split('\n').map(Number).reduce(function(a, b){return  a+b; });
            break;
        default:;
    } // switch
} // ff_nameoftotalelement_action
I tested this and it works, I can add new value and calculate.
When you click on total and then anywhere on the form the total is displayed

P.S. instead of blur as Actions you can use click
Then on clik on total you get sum

Here is example:

File Attachment:

File Name: textareacal2.zip
File Size:7 KB

when you click on total sum is displayed


Regards,
Tihana
Attachments:

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

Last edit: Post by tihana.krivic.

Calculate Textarea 2 weeks 1 day ago #249225

  • Topic Author
  • mrperfectpz
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 337
  • Thanks: 0
Works perfect, thankyou

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

  • Page:
  • 1
Time to create page: 0.049 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!