# Floors Doors & More: Area Calculator Javascript

Sep 24th, 2020 (edited)
692
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. <!-- SQUARE FOOTAGE CALCULATOR -->
2. <script>
3.     function displayCalc() {
4.         document.getElementById("showCalc").innerHTML = "<h2>Square Footage Calculator</h2>";
5.         calculator.style.visibility = "visible";
6.     }
7.
8.     function calculate() {
9.
10.         let productArea = parseFloat(document.getElementById('pArea').innerHTML);
11.
12.         let myLength1 = document.getElementById('tLength1').value;
13.         let myWidth1 = document.getElementById('tWidth1').value;
14.         let myArea1 = myLength1 * myWidth1;
15.
16.         let myLength2 = document.getElementById('tLength2').value;
17.         let myWidth2 = document.getElementById('tWidth2').value;
18.         let myArea2 = myLength2 * myWidth2;
19.
20.         let myLength3 = document.getElementById('tLength3').value;
21.         let myWidth3 = document.getElementById('tWidth3').value;
22.         let myArea3 = myLength3 * myWidth3;
23.
25.
26.         let myTotalArea = myArea1 + myArea2 + myArea3;
27.         if (needExtra.checked == true) {
28.             myTotalArea = myTotalArea + (myTotalArea * 0.1);
29.         }
30.         document.getElementById('tArea').value = myTotalArea;
31.
32.         if ((myTotalArea / productArea) >= 1) {
33.             var myResult = Math.ceil(myTotalArea / productArea);
34.         } else {
35.             var myResult = 1;
36.         }
37.
38.         document.getElementById('Quantity-product-template').value = myResult;
39.     }
40. </script >
41. <!-- End - SQUARE FOOTAGE CALCULATOR -->
RAW Paste Data