ja for globale variabler er jo 10 gange bedre!!
Pak det i det mindste ind i et object
- var App = {
- TAXRATE : 0.0925,
- PRICEPERDONUT : 0.50,
-
- orderCalc : function(){
- var totalOfCakeDonuts = parseFloat(document.getElementById('cakedonuts').value),
- totalOfGlazedDonuts = parseFloat(document.getElementById('glazeddonuts').value),
- subTotal = (totalOfCakeDonuts + totalOfGlazedDonuts) * PRICEPERDONUT,
- tax = subTotal * TAXRATE,
- total = subTotal + tax;
-
- document.getElementById("subtotal").value = "$" + subTotal.toFixed(2);
- document.getElementById("tax").value = "$" + tax.toFixed(2);
- document.getElementById("total").value = "$" + total.toFixed(2);
- }
- };