I've created an order form for sandwiches (s. screenshot Order_Form.jpg). It allows to order 0-9 units of 6 different variations of sandwiches. Whenever the user enters a digit into one of the six fields, the function calculate() is called [via an extra param [b]onchange=calculate()[/b]].
Here the function:
function calculate () {
var PG = 1.8;
var PE = 1.2;
var Preis = 0.0;
Sal = parseInt(jQuery("[name='Salami']").val());
SalG = parseInt(jQuery("[name='SalamiGarniert']").val());
Kas = parseInt(jQuery("[name='Käse']").val());
KasG = parseInt(jQuery("[name='KäseGarniert']").val());
Wur = parseInt(jQuery("[name='Wurst']").val());
WurG = parseInt(jQuery("[name='WurstGarniert']").val());
Preis = (SalG + KasG + WurG) * PG + (Sal + Kas + Wur) * PE;
Preis = Preis.toFixed(2);
jQuery("[name='Summe']").val(Preis);
}
The function works fine, but I would like to format the results es a €-value. Given the example from the screenshot, this would be "€ 4,80".
Is there an easy way to achieve that kind of formatting?
http://systemtest.mittelpunkt-aufenau.de/broetchen-bestellen.html
Here the function:
function calculate () {
var PG = 1.8;
var PE = 1.2;
var Preis = 0.0;
Sal = parseInt(jQuery("[name='Salami']").val());
SalG = parseInt(jQuery("[name='SalamiGarniert']").val());
Kas = parseInt(jQuery("[name='Käse']").val());
KasG = parseInt(jQuery("[name='KäseGarniert']").val());
Wur = parseInt(jQuery("[name='Wurst']").val());
WurG = parseInt(jQuery("[name='WurstGarniert']").val());
Preis = (SalG + KasG + WurG) * PG + (Sal + Kas + Wur) * PE;
Preis = Preis.toFixed(2);
jQuery("[name='Summe']").val(Preis);
}
The function works fine, but I would like to format the results es a €-value. Given the example from the screenshot, this would be "€ 4,80".
Is there an easy way to achieve that kind of formatting?
http://systemtest.mittelpunkt-aufenau.de/broetchen-bestellen.html