× Form Help

calculating fields based on different conditional fields

  • Leni14
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 47
  • Thank you received: 0

Leni14 replied the topic: calculating fields based on different conditional fields

sure.
#238994
Attachments:
  • Posts: 2969
  • Karma: 100
  • Thank you received: 393

mihaela replied the topic: calculating fields based on different conditional fields

Hello,

Thank you for the package.

I see that you have not replaced 'switcher' with 'Satz' in this code:
else if(ff_getElementByName('switcher').value == "Tagessatz") {
After I've changed it, the amount was calculated properly.

I suggest that you also add Actionscript to the Satz element to get better performance.
Add code like this:
function ff_Satz_action(element, action)
{
if(ff_getElementByName('Satz').value == "Stundensatz") {
    ff_getElementByName('netto').value =
    Number(ff_getElementByName('Stundensatz').value) * Number(ff_getElementByName('Anzahl').value);
    }
else if(ff_getElementByName('Satz').value == "Tagessatz") {
    ff_getElementByName('netto').value =
    Number(ff_getElementByName('Tagessatz').value) * Number(ff_getElementByName('Anzahl').value);
    }
} // ff_Satz_action

Let me know whether after this change it works properly.

Regards,

Mihaela
#239003
The following user(s) said Thank You: Leni14
  • Leni14
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 47
  • Thank you received: 0

Leni14 replied the topic: calculating fields based on different conditional fields

Thank you very very much.

Can you help me further?

I have another switcher "Umsatzsteuerpflichtig" with the values:
0;ja;19
1;nein;0

it should go ahead with calculating depending on this switcher:

if it's set to "ja" field "Umsatzsteuer" should calculate "netto" * 19%
and field "Rechnungsbetrag" should be "netto" + "Umsatzsteuer" + "Auslagen"

if it's set to "nein" field "Umsatzsteuer" is not visible
and field "Rechnungsbetrag" should be "netto" + "Auslagen"

Would be amazing if you could tell me where to put which code.
#239004
  • Posts: 2969
  • Karma: 100
  • Thank you received: 393

mihaela replied the topic: calculating fields based on different conditional fields

Hello again,

I'm glad that the first part is now working.

As for the second question, maybe the easiest way to make the calculation in this case, so that you don't have to add code to each Actionscript is to put the calculation in the Initialization script as follows.

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


function calc() {

if(ff_getElementByName('Umsatzsteuerpflichtig').value == "19") {

    ff_getElementByName('Umsatzsteuer').value =
    Number(ff_getElementByName('netto').value) * 0.19;

    ff_getElementByName('Rechnungsbetrag').value =
    Number(ff_getElementByName('netto').value) + Number(ff_getElementByName('Umsatzsteuer').value) + Number(ff_getElementByName('Auslagen').value);
    }
else if(ff_getElementByName('Umsatzsteuerpflichtig').value == "0") {

    ff_getElementByName('Umsatzsteuer').value = 0;

    ff_getElementByName('Rechnungsbetrag').value =
    Number(ff_getElementByName('netto').value) + Number(ff_getElementByName('Auslagen').value);
    }

}

Let me know whether this works as you wanted.

Regards,

Mihaela
#239006
  • Leni14
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 47
  • Thank you received: 0

Leni14 replied the topic: calculating fields based on different conditional fields

Thank you! This works perfectly!
#239013
  • Posts: 2969
  • Karma: 100
  • Thank you received: 393

mihaela replied the topic: calculating fields based on different conditional fields

Great!

I'm glad that this is working as you wanted.

Regards,

Mihaela
#239017
Moderators: ForumSupporttomeperica
Time to create page: 0.055 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here