Creating a Receipt

Item
Description
Number
Cost
Qty
Sub Total
Rake
Metal gravel rake, best used for distributing pea gravel or similar sized material. Sturdy and long-lasting, this will be in your tool shed for years to come.
RK-2702
$29.99
Shovel, Round
Round nosed shovel with 4' handle and rubber grip. Great for digging holes, trenching, or general purpose digging. 5 year warranty comes standard with all BrandX tools.
SR-1933
$32.74
Shovel, Square
Square nosed shovel with 4' handle and rubber grip. Great for scraping, scooping rocks, or general purpose digging. 5 year warranty comes standard with all BrandX tools.
SS-1934
$33.49
Wheelbarrow
3 yard metal wheelbarrow, with pneumatic tire, and rubber handle grips. Galvanized for long-lasting weather protection. 5 year warranty comes standard with all BrandX tools.
WB-0961
$65.89

Code Example

 <script>
  let date = new Date();
  function calculatePrice(myform){  
 
  /* RAKE */ 
    let rakeNum = document.getElementById("rakeCount").value;
    let rakeCost = 29.99;
    let rakeSubTotal = rakeNum * rakeCost;
    let rakeName = "Rake";
    document.getElementById('subTotalRake').innerHTML = rakeSubTotal.toFixed(2); /* DISPLAY ITME SUBTOTAL IN TABLE */

 /* SHOVEL ROUND */ 
    let shovelRoundNum = document.getElementById("shovelRoundCount").value;
    let shovelRoundCost =  32.74;
    let shovelRoundSubTotal = shovelRoundNum * shovelRoundCost;
    let shovelName = "Shovel, Round";
    document.getElementById('subTotalShovel').innerHTML = shovelRoundSubTotal.toFixed(2);

 /* SHOVEL SQUARE */ 
    let shovelSquareNum = document.getElementById("shovelSquareCount").value;
    let shovelSquareCost =  33.49;
    let shovelSquareSubTotal = shovelSquareNum * shovelSquareCost;
    let shovelSquareName = "Shovel, Square";
    document.getElementById('subTotalSquareShovel').innerHTML = shovelSquareSubTotal.toFixed(2);

 /* WHEELBARROW */ 
    let wheelbarrowNum = document.getElementById("wheelbarrowCount").value;
    let wheelbarrowCost =  65.89;
    let wheelbarrowSubTotal = wheelbarrowNum * wheelbarrowCost;
    let wheelbarrowName = "Wheelbarrow";
    document.getElementById('subTotalWheelbarrow').innerHTML = wheelbarrowSubTotal.toFixed(2);

 /* CALCULATE TOOLS SUBTOTAL */
    let toolSubTotal = rakeSubTotal + shovelRoundSubTotal + shovelSquareSubTotal + wheelbarrowSubTotal; 
    let tax = .095;
    let totalTaxDue = toolSubTotal * tax;
    let totalDue = totalTaxDue + toolSubTotal;
    document.getElementById('receipt').style.visibility = "visible";

 /* IF NO RAKES WERE SELECTED, DISPLAY NO LINE ITEM */
    if(document.getElementById('rakeCount').value >= 1) {
      document.getElementById('lineItems').innerHTML = rakeName + " x " + document.getElementById("rakeCount").value + "
"; document.getElementById('itemPrice').innerHTML = rakeCost + "
"; } else { document.getElementById('lineItems').innerHTML; } /* IF NO ROUND SHOVELS WERE SELECTED, DISPLAY NO LINE ITEM */ if(document.getElementById('shovelRoundCount').value >= 1) { document.getElementById('lineItems').innerHTML += shovelName + " x " + document.getElementById("shovelRoundCount").value + "
"; document.getElementById('itemPrice').innerHTML += shovelRoundCost + "
"; } else { document.getElementById('shovelRoundCount').innerHTML; } /* IF NO SQUARE SHOVELS WERE SELECTED, DISPLAY NO LINE ITEM */ if(document.getElementById('shovelSquareCount').value >= 1) { document.getElementById('lineItems').innerHTML += shovelSquareName + " x " + document.getElementById("shovelSquareCount").value + "
"; document.getElementById('itemPrice').innerHTML += shovelSquareCost + "
"; } else { document.getElementById('shovelSquareCount').innerHTML; } /* IF NO WHEELBARROWS WERE SELECTED, DISPLAY NO LINE ITEM */ if(document.getElementById('wheelbarrowCount').value >= 1) { document.getElementById('lineItems').innerHTML += wheelbarrowName + " x " + document.getElementById("wheelbarrowCount").value + "
"; document.getElementById('itemPrice').innerHTML += wheelbarrowCost + "
"; } else { document.getElementById('wheelbarrowCount').innerHTML; } document.getElementById('data').innerHTML += "

Subtotal: $" + toolSubTotal.toFixed(2) + "
"; document.getElementById('data').innerHTML += "Tax: $" + totalTaxDue.toFixed(2) + "
"; document.getElementById('data').innerHTML += "Total Due: $" + totalDue.toFixed(2); document.getElementById('rBottom').innerHTML = "Thank you for shopping with us.
" + date.toString() document.getElementById('rTop').innerHTML = "Praesto Creative
1234 Five Street MyTown, CA 95000
(234) 567-7899"; } </script>