TOPIC:

[ready] Berechnung mit 2-Kommastellen 2 weeks 3 days ago #247981

  • Topic Author
  • 1987Jan
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 103
  • Thanks: 0
Hey,

ich habe schon sehr viele Lösungsvorschläge gesucht aber bisher hat es noch nicht so funktioniert, wie ich es wollte.

Es geht um den Befehl .toFixed(2)

Ich habe ein Formular für die Abrechnung von Einsätzen über QuickMode erstellt.

Beispiel hier : Getränkekisten

Anzahl der Kisten
function ff_trinken_action(element, action)
{
ff_getElementByName('su_trinken').value =
Number(ff_getElementByName('trinken').value) *
Number(ff_getElementByName('ep_trinken').value);
}
// ff_trinken_action

Summe des Einzelpreises
function ff_ep_trinken_action(element, action)
{
ff_getElementByName('su_trinken').value =
Number(ff_getElementByName('trinken').value) *
Number(ff_getElementByName('ep_trinken').value);
}
// ff_ep_trinken_action

Gesamtsumme
function ff_su_trinken_action(element,action)
{
ff_getElementByName('su_trinken').value = 0;
{
ff_getElementByName('su_trinken').value =
Number(ff_getElementByName('trinken').value) *
Number(ff_getElementByName('ep_trinken').value);
}
}
// ff_su_trinken_action

Wo kommt nun der .toFixed(2) Befehl hin?
VIELEN Dank im Voraus.

Gruß
Jan

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

Last edit: Post by 1987Jan.

Berechnung mit 2-Kommastellen 2 weeks 2 days ago #247983

  • tihana.krivic's Avatar
  • tihana.krivic
  • Online
  • Moderator
  • Moderator
  • Posts: 1259
  • Karma: 3
  • Thanks: 110
Hi,

try this:
1.
function ff_trinken_action(element, action)
{
var first=ff_getElementByName('trinken').value;
var second=ff_getElementByName('ep_trinken').value;
var third=Number(first)*Number(second);
ff_getElementByName('su_trinken').value=third.toFixed(2);
}// ff_trinken_action
2.
function ff_ep_trinken_action(element, action)
{
var first=ff_getElementByName('trinken').value;
var second=ff_getElementByName('ep_trinken').value;
var third=Number(first)*Number(second);
ff_getElementByName('su_trinken').value=third.toFixed(2);
}
// ff_ep_trinken_action
3.
function ff_su_trinken_action(element,action)
{
ff_getElementByName('su_trinken').value = 0;
{
var first=ff_getElementByName('trinken').value;
var second=ff_getElementByName('ep_trinken').value;
var third=Number(first)*Number(second);
ff_getElementByName('su_trinken').value=third.toFixed(2);
}
}
// ff_su_trinken_action
With this the sum will be rounded to two decimal places, or you want that all fields be rounded to two decimal places?

Regards,
Tihana
The following user(s) said Thank You: 1987Jan

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

Last edit: Post by tihana.krivic.

Berechnung mit 2-Kommastellen 2 weeks 2 days ago #247990

  • Topic Author
  • 1987Jan
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 103
  • Thanks: 0
THAAAAAANK YOU !!!! :kiss:

Nun habe ich noch ein EXTRA Element wo alle Summe berechnet werden sollen, damit ich auch ein "Gesamtergebenis" habe.

Was ist falsch?
function ff_summe_action(element,action)
{
ff_getElementByName('summe').value = 0;
{
var first=ff_getElementByName('su_trinken').value;
var second=ff_getElementByName('su_darvoben').value
var fourth=ff_getElementByName('su_kaffee').value
var fifth=ff_getElementByName('su_kleinm').value
var sixth=ff_getElementByName('su_propan').value
var seventh=ff_getElementByName('su_toast').value
var eighth=ff_getElementByName('su_brotchen').value
var ninth=ff_getElementByName('su_wurst').value
var tenth=ff_getElementByName('su_senf').value
var eleventh=ff_getElementByName('su_suppe').value
var twelfth=ff_getElementByName('su_naschen').value
var thirteenth=ff_getElementByName('su_nudeln').value
var tourteenth=ff_getElementByName('su_mtw').value
var fifteenth=ff_getElementByName('su_ktw').value
var sixteenth=ff_getElementByName('su_lkw').value
var third=Number(first)+Number(second)+Number(fourth)+Number(fifth)+Number(sixth)+Number(seventh)+Number(eighth)+Number(ninth)+Number(tenth)+Number(eleventh)+Number(twelfth)+Number(thirteenth)+Number(tourteenth)+Number(fifteenth)+Number(sixteenth);
ff_getElementByName('summe').value=third.toFixed(2);
}
}
// ff_su_trinken_action

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

Last edit: Post by 1987Jan.

Berechnung mit 2-Kommastellen 2 weeks 2 days ago #248012

  • Eddy.vh's Avatar
  • Eddy.vh
  • Away
  • Gold Breezer
  • Gold Breezer
  • Posts: 423
  • Karma: 4
  • Thanks: 68
Hi,
Es fehlen viele Semikolon nach ".value".
Korrigier das und es müsste klappen.

MfG.
Eddy
The following user(s) said Thank You: tihana.krivic

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

Berechnung mit 2-Kommastellen 2 weeks 2 days ago #248013

  • tihana.krivic's Avatar
  • tihana.krivic
  • Online
  • Moderator
  • Moderator
  • Posts: 1259
  • Karma: 3
  • Thanks: 110
Hi,

@1987Jan sorry I saw your post before you edit it.
Please do what Eddy wrote, add semicolon:
function ff_summe_action(element,action)
{
ff_getElementByName('summe').value = 0;
{
var first=ff_getElementByName('su_trinken').value;
var second=ff_getElementByName('su_darvoben').value;
var fourth=ff_getElementByName('su_kaffee').value;
var fifth=ff_getElementByName('su_kleinm').value;
var sixth=ff_getElementByName('su_propan').value;
var seventh=ff_getElementByName('su_toast').value;
var eighth=ff_getElementByName('su_brotchen').value;
var ninth=ff_getElementByName('su_wurst').value;
var tenth=ff_getElementByName('su_senf').value;
var eleventh=ff_getElementByName('su_suppe').value;
var twelfth=ff_getElementByName('su_naschen').value;
var thirteenth=ff_getElementByName('su_nudeln').value;
var tourteenth=ff_getElementByName('su_mtw').value;
var fifteenth=ff_getElementByName('su_ktw').value;
var sixteenth=ff_getElementByName('su_lkw').value;
var third=Number(first)+Number(second)+Number(fourth)+Number(fifth)+Number(sixth)+Number(seventh)+Number(eighth)+Number(ninth)+Number(tenth)+Number(eleventh)+Number(twelfth)+Number(thirteenth)+Number(tourteenth)+Number(fifteenth)+Number(sixteenth);
ff_getElementByName('summe').value=third.toFixed(2);
}
}
// ff_su_trinken_action

Regards,
Tihana

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

Berechnung mit 2-Kommastellen 2 weeks 2 days ago #248016

  • Topic Author
  • 1987Jan
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 103
  • Thanks: 0
Leider berechnet nun die "summe" gar nichts mehr.

Habe die " ; " eingefügt.
function ff_summe_action(element,action)
{
ff_getElementByName('summe').value = 0;
{
var first=ff_getElementByName('su_trinken').value;
var second=ff_getElementByName('su_darvoben').value;
var fourth=ff_getElementByName('su_kaffee').value;
var fifth=ff_getElementByName('su_kleinm').value;
var sixth=ff_getElementByName('su_propan').value;
var seventh=ff_getElementByName('su_toast').value;
var eighth=ff_getElementByName('su_brotchen').value;
var ninth=ff_getElementByName('su_wurst').value;
var tenth=ff_getElementByName('su_senf').value;
var twelfth=ff_getElementByName('su_naschen').value;
var thirteenth=ff_getElementByName('su_nudeln').value;
var tourteenth=ff_getElementByName('su_mtw').value;
var fifteenth=ff_getElementByName('su_ktw').value;
var sixteenth=ff_getElementByName('su_lkw').value;
var third=Number(first)+Number(second)+Number(fourth)+Number(fifth)+Number(sixth)+Number(seventh)+Number(eighth)+Number(ninth)+Number(tenth)+Number(twelfth)+Number(thirteenth)+Number(tourteenth)+Number(fifteenth)+Number(sixteenth);
ff_getElementByName('summe').value=third.toFixed(2);
}
}
// ff_summe_action

Das Element "summe" ist all den anderen Elementen nicht vorhanden. Kann das daran liegen?

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

Moderators: ForumSupport
Time to create page: 0.053 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!