Skript, welches doppelt ein Feld befüllen soll

  • palatzflorian
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0

palatzflorian created the topic: Skript, welches doppelt ein Feld befüllen soll

Hallo.
Ich versuche krampfhaft seit einigen Stunden folgendes Problem zu lösen. Ich habe mich durch das Forum gekämpft, jedoch konnte ich bis dato nichts brauchbares finden. Gut möglich, dass dies mein Fehler ist und ich mich zu brasselig anstelle. Sollte dem so sein, Sorry.

Es geht um folgendes:
Ich möchte ein Formular online stellen, welches zum einen Daten vom Kunden abfragt, und zeitgleich ihm das Produkt kostentechnisch in einer E-Mail bestätigt.


Ich habe hierzu ein Auswahlfeld:
0;Basic;1000
0;Premium;1800
0;Ultimate;2500

Sowie ein Checkboxgruppe welche optional dazu gebucht werden kann.
0;Paket 1;180
0;Paket 2;180
0;Paket 3;140
0;Paket 4;240

Nun würde ich in einem weiteren Feld gerne die Gebühr vom Auswahlfeld angezeigt bekommen.

Ein weiteres soll die Werde aus der Checkboxgruppe addieren.

Das dritte wiederrum die beiden Werte zusammen addieren.

Das war mein erstes Scheitern...
Das eigentliche Problem folgt nun jedoch.

Es handelt sich hierbei um Einmalkosten.

Paket 2 hat jedoch zusätzlich eine mtl. Gebühr von 20 Euro,
Paket 4 von 60 Euro.
Die 3 Hauptpakete vom Auswahlfeld insgesamt eine mtl. Grundgebühr von 60 Euro.
Im Idealfall soll nun das nächste Feld die mtl. Gebühren angeben.


Habt ihr eine Idee ob, bzw. wenn ja, wie dies umsetzbar ist?


Viele Liebe Grüße


Florian
#213790
  • Posts: 2222
  • Karma: 44
  • Thank you received: 279

marko.bosnjak replied the topic: Skript, welches doppelt ein Feld befüllen soll

Hello,

we are currently little short on German speaking supporters. Could you translate your question in English and we'll assist you? Thank you.

Regards,
Marko

======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!
#213816
  • palatzflorian
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0

palatzflorian replied the topic: Script, which should double fill a field

Hello.
I have desperately been trying to solve the following problem for a few hours already.
So I fought my way through the forum, but I have not found any useful information so far.
Well maybe I’m just being stupid... If so, Sorry.

It’s about:
I would like to submit a form online, which on the one hand queries data from the customer, and at the same time confirms all about the cost of the product in an e-mail.


I have these “packages” for the customer to choose:
0; Basic 1000
0; Premium; 1800
0; Ultimate, 2500

As well as a “checkbox group” which can be booked optionally.
0; Package 1; 180
0; Package 2; 180
0, package 3, 140
0, package 4, 240

Now I would like to have the fee from the selection field in another field.
Another field should add the value of the checkbox group.

The third, in turn, should add those two values ​​together.

That was my first failure ...
The real problem comes now.

These are one-time costs.

However, package 2 has an additional monthly Fee of 20 euros,
Package 4 a monthly fee of 60 euros.
The 3 main packages from the selection box are one monthly basic fee of 60 euros total.
Ideally, the next field should show the monthly fees.


Do you have an idea of how this can be done?


Many greetings


Florian
#214849
  • Posts: 2222
  • Karma: 44
  • Thank you received: 279

marko.bosnjak replied the topic: Script, which should double fill a field

Hello Florian,

I've created an example form.
I think this includes everything you need.
I'll explain it step by step:

1) I created a select list named "packages" with following options:
0;Select A Package;0
0;Basic;1000
0;Premium;1800
0;Ultimate;2500
In the Advanced tab > Actionscript > Type > Custom > Actions > Change I implemented the following code:
function ff_packages_action(element, action)
{
ff_packages_fee_action(element, action); 
ff_monthly_fee_main_action(element, action); 
}
This is only used for proceeding selecting values to 2 following elements named "packages_fee" and "monthly_fee_main".

2) I created a textfield named "packages_fee" which will display the chosen value from the select list and proceed the value to the total element. I implemented the following code in the Advanced tab > Actionscript > Type > Custom > Actions > Change:
function ff_packages_fee_action(element, action)
{
ff_getElementByName('packages_fee').value = Number(ff_getElementByName('packages').value);
ff_total_action(element, action); 
}

3) Then comes the checkbox group named "additional". It has following options:
0;Package 1;180
0;Package 2;180
0;Package 3;140
0;Package 4;240
In the Advanced tab > Actionscript > Type > Custom > Actions > Change I implemented the following code:
function ff_additional_action(element, action)
{
ff_additional_fee_action(element, action);
ff_monthly_fee_additional2_action(element, action);
ff_monthly_fee_additional4_action(element, action);
}
This is used for proceeding selecting values to 2 following elements named "additional_fee", "monthly_fee_additional2" and "monthly_fee_additional4".

4) Then I created a textfield named "additional_fee" which will calculate the value of the checkbox group and proceed the value to the "total" element. I implemented the following code in the Advanced tab > Actionscript > Type > Custom > Actions > Change:
function ff_additional_fee_action(element, action)
{
var a=0;
opts = JQuery("[name=\"ff_nm_additional[]\"]");
for (o = 0; o < opts.length; o++){
if (opts[o].checked){
a = parseInt(a) + parseInt(opts[o].value);
}
}
ff_getElementByName('additional_fee').value = parseInt(a);
ff_total_action(element, action);
}

5) The "total" element ha the following code implemented in the Advanced tab > Actionscript > Type > Custom > Actions > Change:
function ff_total_action(element, action)
{
ff_getElementByName('total').value = Number(ff_getElementByName('packages_fee').value) + Number(ff_getElementByName('additional_fee').value);
}
Basically it will only add values from "packages_fee" and "additional_fee" elements.

6) After that, we move onto the monthly fees.
I created a textfield named "monthly_fee_main" with the following script implemented in the Advanced tab > Actionscript > Type > Custom > Actions > Change:
function ff_monthly_fee_main_action(element, action)
{
var package= JQuery("[name=\"ff_nm_packages[]\"] option:selected").text();
if (package == 'Basic') {
ff_getElementByName('monthly_fee_main').value = 60;
}
else if (package == 'Premium') {
ff_getElementByName('monthly_fee_main').value = 60;
}
else if (package == 'Ultimate') {
ff_getElementByName('monthly_fee_main').value = 60;
}
else {
ff_getElementByName('monthly_fee_main').value = 0;
}
ff_total_monthly_fee_action(element, action);
}
It will add display the following value depending on the selected option from the select list. In your case, they are all 60.

7) Then I created 2 textfields which will show additional monthly fees. In your case, it's package 2 and 4. Each of those 2 textfields is initially turned off. When being clicked on, they will show up and display the correct value. The textfields are named "monthly_fee_additional2" and "monthly_fee_additional4". The first one has this script implemented in the Advanced tab > Actionscript > Type > Custom > Actions > Change:
function ff_monthly_fee_additional2_action(element, action)
{
    switch (action)
     {
          case 'change':
          vals = '';
          opts = JQuery("[name=\"ff_nm_additional[]\"]");
          if (opts[1].checked){
              ff_getElementByName('monthly_fee_additional2').value = 20;
              bfToggleFields('on','element','monthly_fee_additional2',bfDeactivateField);
          }
          else{
             ff_getElementByName('monthly_fee_additional2').value = "";
             bfToggleFields('off','element','monthly_fee_additional2',bfDeactivateField);
          }
      }
ff_total_monthly_fee_action(element, action);
}
The second one has almost the same script implemented in the Advanced tab > Actionscript > Type > Custom > Actions > Change:
function ff_monthly_fee_additional4_action(element, action)
{
    switch (action)
     {
          case 'change':
          vals = '';
          opts = JQuery("[name=\"ff_nm_additional[]\"]");
          if (opts[3].checked){
              ff_getElementByName('monthly_fee_additional4').value = 60;
              bfToggleFields('on','element','monthly_fee_additional4',bfDeactivateField);
          }
          else{
             ff_getElementByName('monthly_fee_additional4').value = "";
             bfToggleFields('off','element','monthly_fee_additional4',bfDeactivateField);
          }
      }
ff_total_monthly_fee_action(element, action);
}
NOTE: Because of the visibility rules, I implemented the following line in form properties > Advanced tab > Visibility rules:
turn on element mydummy if yourdummy is something

8) In the end comes the "total_monthly_fee" textfield element. I implemented the following script in the Advanced tab > Actionscript > Type > Custom > Actions > Change:
function ff_total_monthly_fee_action(element, action)
{
ff_getElementByName('total_monthly_fee').value = Number(ff_getElementByName('monthly_fee_main').value) +Number(ff_getElementByName('monthly_fee_additional2').value) + Number(ff_getElementByName('monthly_fee_additional4').value);
}
It will calculate the total amount from main and additional monthly fees.
That's it.

I'll attach you the form. Install it and test it out.
Let me know if it's working for you.

Regards,
Marko

======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!
#214892
Attachments:
Moderators: ForumSupporttomeperica
Time to create page: 0.072 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